REM CAC is free software: you can redistribute it and/or modify
REM it under the terms of the GNU General Public License as published by
REM the Free Software Foundation, either version 2 of the License, or
REM (at your option) any later version.
REM
REM CAC is distributed in the hope that it will be useful,
REM but WITHOUT ANY WARRANTY; without even the implied warranty of
REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
REM GNU General Public License for more details.
REM
REM You should have received a copy of the GNU General Public License
REM along with CAC.  If not, see <https://www.gnu.org/licenses/>.
REM
REM CAC
REM Copyright (C) 1990 Richard Emsley 

 REM >CAC
 MODE 12 : COLOUR 0 : COLOUR 191 : CLS
 *CONFIGURE spritesize 300K
 errorbeforedisplay$ = "y"
 ON ERROR PROCerror
 biga% = 10^5 : bigb% = 0 : bigc% = 0 : bigd% = 10^5 : box$ = "n"
 :
 PROCtobegin
 END
 :
 REM*******************************
 :
 DEF PROCawait
 :
 IF easiermenus$ = "n" THEN
 PROCwindow(20,69,60,55)
 PRINT'" Functions                           F"
 PRINT " Add one note (fully defined)        O"
 PRINT " Delete notes                        X"
 PRINT " Copy/move notes                     C"
 PRINT " Define a group of values            G"
 PRINT " Add the group of values             A"
 PRINT " Rhythmicize                         R"
 PRINT " Display                             D"
 PRINT " Play                                P"
 PRINT " Various                             V"
 PRINT " Undo last operation                 Z"
 PRINT " Save                                S"
 PRINT " Quit                                Q"
 ELSE
 PROCwindow(20,69,60,42)
 PRINT' " Functions                           F"
 PRINT' " Add one note (fully defined)        O"
 PRINT' " Delete notes                        X"
 PRINT' " Copy/move notes                     C"
 PRINT' " Define a group of values            G"
 PRINT' " Add the group of values             A"
 PRINT' " Rhythmicize                         R"
 PRINT' " Display                             D"
 PRINT' " Play                                P"
 PRINT' " Various                             V"
 PRINT' " Undo last operation                 Z"
 PRINT' " Save                                S"
 PRINT' " Quit                                Q"
 ENDIF
 :
 CASE GET$ OF
  WHEN "f" : PROCfunctionreception
  WHEN "o" : PROCaddonenote
  WHEN "x" : PROCdelete
  WHEN "c","1","`" : PROCcopy
  WHEN "g", "3" : PROCsubawaitG
  WHEN "a" : PROCsubawaitA
  WHEN "r" :
   VDU 7
   IF easiermenus$ = "n" THEN PROCwindow(20,69,63,52) ELSE PROCwindow(20,69,63,42)
   CLS
  PRINT'" To rhythmicize attacks, first switch on "
  PRINT'" Rhythmicize Attacks in Display Options "
  PRINT'" (M/V/D/H) then create a group of attacks "
  PRINT'" or copy some attacks or move some attacks "
  PRINT'" to itself, during the course of which you "
  PRINT'" will be invited to rhythmicize them. "
  PRINT'"       (press a key to continue) "
    CASE GET$ OF
     WHEN "m" : PROCdisplay
     OTHERWISE
     PROCdisplay
    ENDCASE
  WHEN "d" : PROCpredisplay
  WHEN "p" : play$ = "play" : PROCplay
  WHEN "m" :



PROCdisplay : REM toggle
  WHEN "v" : PROCplaysubmenu
   WHEN "s" : PROCsave
  WHEN "Z","z" : PROCundo
   WHEN "q" : PROCquit
  OTHERWISE VDU 7 : PROCawait : REM bleep and loop back to start of proc
 ENDCASE
 :
 ENDPROC
 :
 REM*********************************
 :
 DEF PROCsubawaitG
 :
 IF easiermenus$ = "n" THEN
 CLS
 PRINT' " attacks                A"
 PRINT " envelope points        R"
 PRINT " pitches                P"
 PRINT " amplitudes             L"
 PRINT " amplitude gradations   G"
 PRINT " envelopes/glissandos   E"
 PRINT " durations              D"
 PRINT " microtonal inflections M"
 ELSE
 CLS
 PRINT'" attacks                A"
 PRINT'" envelope points        R"
 PRINT'" pitches                P"
 PRINT'" amplitudes             L"
 PRINT'" amplitude gradations   G"
 PRINT'" envelopes/glissandos   E"
 PRINT'" durations              D"
 PRINT'" microtonal inflections M"
 ENDIF
 :
 CASE GET$ OF
  WHEN "A","a" : PROCseriesattacks
  WHEN "R","r" : PROCreleases
  WHEN "P","p", "3" : PROCseriespitches
  WHEN "L","l" : PROCseriesamplitudes
  WHEN "E","e" : PROCseriesenvelopes
  WHEN "G","g" : gradations$ = "y" : PROCseriesenvelopes
  WHEN "D","d" : PROCseriesdurations
  WHEN "M","m" : PROCseriesinflections
  OTHERWISE VDU 7 : PROCsubawaitG
 ENDCASE
 :
 ENDPROC
 :
 REM***********************************
 :
 DEF PROCprearraysetup
 :
 MODE 12 : COLOUR 0 : COLOUR 191
 CLS
 numwaves% = 19
 INPUT'''''" Estimate the maximum number of bars "nobars%
 INPUT''" Estimate the average number of notes per bar in the busiest part "nonotes
 INPUT''" How many voices "numparts%
 :
 DIM insts$(numparts%,2) : instsdimmed$ = "y"
 PRINT''" Do you want to define the voices or use default ones (Y/D)"
 CASE GET$ OF
  WHEN "Y","y" :
   FOR count% = 1 TO numparts%
    PRINT '"   voice ";count%;" is called"
    INPUT name$
    PRINT "   and is in clef (P/T/B/D...TT/TB/BB etc)"
    INPUT clef$
    PRINT "   and has how many staves"
    INPUT staves$
    insts$(count%,0) = name$ : insts$(count%,1) = clef$ : insts$(count%,2) = staves$
   NEXT
  WHEN "D","d" :
   FOR count% = 1 TO numparts%
    insts$(count%,0) = "" : insts$(count%,1) = "T" : insts$(count%,2)="1"
   NEXT
  OTHERWISE
 ENDCASE
 :
 REPEAT
 INPUT''" The time signature has how many beats to the bar "factor%
 :
 CASE factor% OF
  WHEN 1,2,3,4,5,6,8,10,12 : success$ = "YES"
  OTHERWISE
  success$ = "NO"
  VDU 7
  PRINT'" Only 1,2,3,4,5,6,8,10 or 12 are allowed "
  PRINT'" press a key to try again"
  CASE GET$ OF
   WHEN "m" : success$ = "NO"
   OTHERWISE
    success$ = "NO"
  ENDCASE
  :
 ENDCASE
 UNTIL success$ = "YES"
 :
 factor% = factor% * 8
 beatfactor% = 960/factor%
 :
 REPEAT
 success$ = "YES"
 PRINT''" of what note value "
 PRINT' "  (minim/half-note = 2 "
 PRINT' "   crotchet/quarter-note = 4 "
 PRINT' "   quaver/eighth-note = 8 "
 PRINT' "   semiquaver/sixteenth-note = 16 "
 INPUT' "   demisemiquaver/thirtysecond-note = 32) "beams%
 :
 CASE beams% OF
  WHEN 2 : beams% = 2
  WHEN 4 : beams% = 3
  WHEN 8 : beams% = 4
  WHEN 16 : beams% = 5
  WHEN 32 : beams% = 6
  OTHERWISE
   PRINT'" sorry, try again "
   success$ = "NO"
 ENDCASE
 UNTIL success$ = "YES"
 :
 manynotes% = nobars%*nonotes
 filename$ = ""
 ENDPROC
 :
 REM***********************************************
 :
 DEF PROCarraysetup
 :
 DIM array%(manynotes%,2,(numparts%-1)) : DIM arrayX%(manynotes%,2,(numparts%-1))
 IF instsdimmed$ = "n" THEN DIM insts$(numparts%,2)
 DIM instsX$(numparts%,2)
 DIM numusedcells%(numparts%-1) :  DIM numusedcellsX%(numparts%-1)
 DIM cell%(1999), bar%(1999)
 DIM attacks1%(10000), attacks2%(10000), attacks3%(10000), attacks4%(10000), attacks5%(10000)
 DIM pitches%(10000), pitches1%(10000), pitches2%(10000), amplitudes%(10000), envelopes%(10000)
 DIM durations%(10000), glissandos%(10000), inflections%(10000)
 DIM pitchset%(numparts%+47), ampset%(numparts%+47), envset%(numparts%+47), durset%(numparts%+47), glissset%(numparts%+47), infset%(numparts%+47)
DIM pitchsetX%(numparts%+47), ampsetX%(numparts%+47), envsetX%(numparts%+47), dursetX%(numparts%+47), glisssetX%(numparts%+47)
 DIM functionattacks(10000)
 DIM nodes%(47), nodes1%(47)
 DIM dur%(999), proportion%(999), rhythmicattacks%(999), groupattacks%(999)
 DIM error%(999), notategroup%(999,1), errororder%(999), errororder1%(999)
 DIM disarray%(nobars%,3,(numparts%-1)) : DIM disarrayX%(nobars%,3,(numparts%-1))
 DIM displayvoices%(numparts%), holddisplay%(numparts%), rgroup%(6), longinsts$(2,2), staves%(6)
 DIM displayvoices1%(numparts%) :  DIM displayvoicesX%(numparts%)
 DIM value%(2), pos%(2), longbeamposn%(numparts%), shortbeamposn%(numparts%), actbeamposn%(numparts%), shortamppos%(numparts%), longamppos%(numparts%), actamppos%(numparts%)
 DIM longbeamposnX%(numparts%), shortbeamposnX%(numparts%), shortampposX%(numparts%), longampposX%(numparts%)
DIM longstemdir$(numparts%-1), shortstemdir$(numparts%-1)
DIM longstemdirX$(numparts%-1), shortstemdirX$(numparts%-1)
 DIM waveforms$(numparts%), playvoices%(8), lvdata%(8,9), tic%(4), tun%(8)
 DIM waveformsX$(numparts%), lvdataX%(8,9)
 DIM wforms$(19) : waveload$ = "notdone"
 DIM wformsX$(19)
 DIM startoflayersection%(50), shareoflayers%(50,50), chanceoflayer%(50)
 DIM layershare%(50), numattackssections%(50), startofattackssection%(50,50)
 DIM numattax%(50,50,1), attackscontrol$(50)
 DIM numattackssections1%(50), startofattackssection1%(50,200)
 DIM numattax1%(50,200,1), appearances%(50)
 DIM durationscontrol$(50), numdurationssections%(50)
 DIM numdurationssections1%(50), startofdurationssection%(50,200)
 DIM startofdurationssection1%(50,200), doorations%(50,200), doorations1%(50,200)
 DIM numvalues%(50), values(50,50), valuescounter%(50), multiplier$(50)
 DIM multipliermode$(50)
 DIM contoursequences%(50,15), transpositionsequences%(199,1)
 DIM sample%(299), group%(7), contours%(69,7), octavesequences%(50,48,11)
 DIM pitchnames$(47), octaveloop%(48), distortparas%(50,3)
 DIM numlayerOKsects%(50), OKtouselayers%(50,1), layersOK%(50,50,2)
 DIM layerends%(50), amplitudes1%(10000), dynlayers%(12,5), dynnumbers%(99)
 DIM ampsample%(49)
 DIM tempi%(nobars%), bannedpitches%(80), bannedints%(24,2), triednotes%(88)
 DIM tempiX%(nobars%)
 DIM extractinfo%(20), redpitches%(9,30), numredpitches%(9), holdstartcell%(numparts%)
 DIM remarks$(nobars%,1), quickdisplay%(numparts%), prequickdisplay%(numparts%), thebeats%(15)
 DIM remarksX$(nobars%,1)
 DIM envattacks%(3000), envpitches%(3000), taken%(19)
 FOR count% = 0 TO nobars% : tempi%(count%) = 30 : NEXT
 FOR count% = 0 TO 47 : READ name$ : pitchnames$(count%) = name$ : NEXT
 DATA "C 1/4 flat","C 1/8 flat","C nat","C 1/8 shrp","C 1/4 shrp"
 DATA "C 3/8 shrp","D flat","D 3/8 flat","D 1/4 flat","D 1/8 flat"
 DATA "D nat","D 1/8 shrp","D 1/4 shrp","D 3/8 shrp","E flat","E 3/8 flat"
 DATA "E 1/4 flat","E 1/8 flat","E nat","E 1/8 shrp","E 1/4 shrp"
 DATA "F 1/8 flat","F nat","F 1/8 shrp","F 1/4 shrp","F 3/8 shrp"
 DATA "F shrp","G 3/8 flat","G 1/4 flat","G 1/8 flat","G nat","G 1/8 shrp"
 DATA "G 1/4 shrp","G 3/8 shrp","A flat","A 3/8 flat","A 1/4 flat"
 DATA "A 1/8 flat","A nat","A 1/8 shrp","A 1/4 shrp","A 3/8 shrp"
 DATA "B flat","B 3/8 flat","B 1/4 flat","B 1/8 flat","B nat","B 1/8 shrp"
 DATA 10,1,1,20,2,1,2,21,2,2,1,22,3,1,3,2,23,3,3,1,2,24,3,2,3,1
 DATA 25,3,2,1,3,30,3,1,2,3,31,3,3,2,1,32,4,1,3,4,2,33,4,4,2,1,3
 DATA 34,4,2,3,4,1,35,4,3,2,1,4,36,4,3,1,2,4,37,4,2,4,3,1,38,4,4,1,2,3
 DATA 39,4,1,4,3,2,40,4,1,2,3,4,41,4,4,3,2,1,42,5,1,2,4,5,3
 DATA 43,5,5,4,2,1,3,44,5,2,3,4,5,1,45,5,4,3,2,1,5,46,5,3,1,2,4,5
 DATA 47,5,3,5,4,2,1,48,5,5,1,2,3,4,49,5,1,5,4,3,2,50,5,1,2,3,4,5
 DATA 51,5,5,4,3,2,1,52,6,1,2,4,5,6,3,53,6,6,5,3,2,1,4
 DATA 54,6,2,3,4,5,6,1,55,6,5,4,3,2,1,6,56,6,4,1,2,3,5,6
 DATA 57,6,3,6,5,4,2,1,58,6,6,1,2,3,4,5,59,6,1,6,5,4,3,2
 DATA 60,6,1,2,3,4,5,6,61,6,6,5,4,3,2,1,62,7,1,2,3,5,6,7,4
 DATA 63,7,7,6,5,3,2,1,4,64,7,2,3,4,5,6,7,1,65,7,6,5,4,3,2,1,7
 DATA 66,7,4,1,2,3,5,6,7,67,7,4,7,6,5,3,2,1,68,7,7,1,2,3,4,5,6
 DATA 69,7,1,7,6,5,4,3,2
 FOR count% = 1 TO 47
  READ a%,b%
  contours%(a%,0) = b%
  FOR counter% = 1 TO b%
   READ c%
   contours%(a%,counter%) = c%
  NEXT
 NEXT
 FOR count% = 0 TO numparts%-1 : pitchset%(count%) = 55 : NEXT
 FOR count% = 0 TO numparts%-1 : ampset%(count%) = 3 : NEXT
 FOR count% = 0 TO numparts%-1 : envset%(count%) = 9 : NEXT
 FOR count% = 0 TO numparts%-1 : durset%(count%) = 60 : NEXT
 FOR count% = 0 TO numparts%-1 : glissset%(count%) = 105050  : NEXT
 FOR count% = 0 TO numparts%-1 : infset%(count%) = 50  : NEXT
 *TUNING 0
 VOICES 8
 *CHANNELVOICE 1 WaveSynth-Beep
 *CHANNELVOICE 2 WaveSynth-Beep
 *CHANNELVOICE 3 WaveSynth-Beep
 *CHANNELVOICE 4 WaveSynth-Beep
 *CHANNELVOICE 5 WaveSynth-Beep
 *CHANNELVOICE 6 WaveSynth-Beep
 *CHANNELVOICE 7 WaveSynth-Beep
 *CHANNELVOICE 8 WaveSynth-Beep
 direction$ = ""  : shortstemdir$() = "U" : longstemdir$() = "U" : shortbeamposn%() = 106   :  longbeamposn%() = 106
 manyattacks% = 0 : longbeatsupper% = 739 : longbeatslower% = 405
 tempo% = 19660 : REM default tempo = MM30 per bar
 defaultvoices$ = "y" : PROCassignvoices
 CLS
 VDU 28,20,27,60,15
 COLOUR 0 : COLOUR 191 : CLS
 numbars% = 4 : startbar% = 1
:
numvoices% = numparts%
  FOR count% = 1 TO numvoices%
     displayvoices%(count%) = 1 + count% - 1
     holddisplay%(count%) = 1 + count% - 1
    NEXT
  holdnum% = numvoices%
:
quickdisplay%(1) = 1 : prequickdisplay%(1) = 1
 holdnum% = 1 : holdstart% = 1 : quicknum% = 1 : quickstart% = 1
 prequicknum% = 1 : prequickstart% = 1
 notehead$ = "vsmall" : longscore$ = "y" : startv% = 1 : startv1% = 1
 printing$ = "n"
 barlines$ = "y" : staves$ = "y" : beats$ = "n" : amplitudes$ = "y"
 staves$ = "y" : barlines$ = "y" : names$ = "y" : lowerstave$ = "y"
 accidentals$ = "y" : stems$ = "y" : xoption$ = "y" : durations$ = "n"
 envelopes$ = "y" : glissandos$ = "y" : MM% = 30 : beatstep% = 8
 copyit$ = "OFF" : distort$ = "OFF" : beatnumbers$ = "n"
 wavefilingsystem$ = "notloaded" : manywaves% = 0 : barnosoften% = 5
 reordered$ = "n" : equalized$ = "n" : notenumbers$ = "n" : beatnum_diff$ = "num"
 beatunits$ = "big" : parasdefined$ = "no" : preplaydisplay$ = "n"
 paraset$ = "off" : savevoice$ = "N"
 method$ = "raw" : reordered$ = "n" : quiz$ = "yes" : typeintervals$ = "s"
 displayintervals$ = "n" : numintervals% = 1 :  alterbeatsat% = 0
 compoundpitch% = 12 : compoundquarter% = 24 : compoundeighth% = 48 : compoundcent% = 1200
 defaultsieve = 2 : funcinput$ = "durat" : redpitches$ = "n" : printno% = 0
 seegraph$ = "n" : seeinfo$ = "n" : seereorder$ = "n" : seereorderx$ = "n" : seereordery$ = "n"
 seeequalize$ = "n" : seeequalizex$ = "n" :  seeequalizey$ = "n"
 seerhythmicize$ = "n" : seequery$ = "n" : startfinishdurats$ = "Y" : displayedfunc$ = "n"
 along% = 0 : playnewscreen$ = "y" : seeduration$ = "n" : lower% = 0 : justone$ = "n"
 biga% = 10^5 : bigb% = 0 : bigc% = 0 : bigd% = 10^5 : printinfo$ = "n"
 lowerstart% = 1 : upperstart% = 99 : lowerend% = 1 : upperend% = 99 : toggle$ = "orig"
 quickcopy$ = "y" : quickplay% = 1 : seedurinbts$ = "n" : seedurincrots$ = "n"
 screenvoices$ = "n" : ampoptions$ = "n" : screenmovesby% = 3 : copydownwards$ = "n"
 setalong$ = "y" : numvoicesgiven$ = "n" : envelopedata$ = "none" : deleteone$ = "none"
 quickextract$ = "n" : askaboutpitches$ = "y" : usebottomstave$ = "n" : copysuccessively$ = "n"
 succfirsttime$ = "y" : sequalssection$ = "n"
 addpitches$ = "y" : downwardsspeed% = 50
 horizscroll% = 25 : addten$ = "n" : squarebracket$ = "addten" : queryalong$ = "n"
 waitafterfirst% = 50 : waitaftersecond% = 50 : notenames$ = "n" : holdbackby% = 0
 updisplay% = 1 : vertscroll% = 25 : singlepitch$ = "m" : nosevery% = 1 : startnos% = 1
 reorderpitches$ = "n" : namestaves$ = "nameone" : usebeep$ = "n" : firsttimequick$ = "y"
 onlycontent$ = "n" : compress$ = "n" : quickdisplaywindow$ = "y" : ampmethod$ = "sample"
 holdbackby% = 960 : copytoend$ = "n" : gradations$ = "n" : firstasking$ = "y"
 resetdefaults$ = "n" : firstpitch$ = "y" : usedprev$ = "n" : nodelay$ = "n"
 askprevious$ = "y" : errorbeforedisplay$ = "n" : quitnow$ = "n"
 crossing$ = "n" : easiermenus$ = "y" : copymove$ = "C"
 PROCrhythmdefaults
 :
 ENDPROC
 :
 REM*************************************
 :
 DEF PROCsubawaitA
 :
 IF easiermenus$ = "n" THEN
 PROCwindow(20,69,70,55)
 CLS
 PRINT' " attacks                A"
 PRINT " pitches                P"
 PRINT " amplitudes             L"
 PRINT " envelopes/glissandos   E"
 PRINT " durations              D"
 PRINT " microtonal inflections M"
 ELSE
 PROCwindow(20,69,70,42)
 CLS
 PRINT' " attacks                A"
 PRINT '" pitches                P"
 PRINT '" amplitudes             L"
 PRINT '" envelopes/glissandos   E"
 PRINT '" durations              D"
 PRINT '" microtonal inflections M"
 ENDIF
 :
 CASE GET$ OF
  WHEN "A","a" : PROCinsertattacks
  WHEN "P","p" : PROCinsertpitches
  WHEN "L","l" : PROCinsertamplitudes
  WHEN "E","e" : PROCinsertenvelopes
  WHEN "D","d" : PROCinsertdurations
  WHEN "M","m" : PROCinsertinflections
  OTHERWISE VDU 7 : PROCsubawaitA
 ENDCASE
 :
 ENDPROC
 :
 REM**************************************
 :
 DEF PROCnewnotereception(voice%,barno%,beatno%,pitch%,amp%,env%,dur%,gliss%,inf%)
 :
 value% = (barno% * 10^3) + beatno%
 :
 option% = 0
 :
 ::::::REM if new note is very first to be added::::::

 IF numusedcells%(voice%) = 0 THEN option% = 1
 :
 IF option% <> 1 THEN
 :
 :::::::REM to tack new note on at end:::::
 IF numusedcells%(voice%) > 0 AND value% > (array%((numusedcells%(voice%)-1),0,voice%)) DIV 10^3 THEN option% = 2
 :
 :::::::REM to tack new note on at START::::
 IF numusedcells%(voice%) > 0 AND value% < (array%(0,0,voice%)) DIV 10^3            THEN option% = 3
 :
 ::::::REM to put new note in middle::::::::::
 IF numusedcells%(voice%) > 0 AND value% >= (array%(0,0,voice%)) DIV 10^3 AND value% <= (array%(numusedcells%(voice%)-1,0,voice%)) DIV 10^3 THEN option% = 4
 :
 ENDIF
 :
 IF addingnotes$ = "y" THEN
 CASE option% OF
  WHEN 1 : shunt$ = "Y"
           PROCcellfill(0,voice%,barno%,beatno%,pitch%,amp%,env%,dur%,gliss%,inf%)
  :
  WHEN 2 : shunt$="Y"
           PROCcellfill(numusedcells%(voice%),voice%,barno%,beatno%,pitch%,amp%,env%,dur%,gliss%,inf%)
  :
  WHEN 3 : shunt$="Y"
           PROCshuntright(0)
           PROCcellfill(0,voice%,barno%,beatno%,pitch%,amp%,env%,dur%,gliss%,inf%)
  :
  WHEN 4 : PROCsearch(value%)
           IF shunt$="Y" PROCshuntright(startcell%)
           PROCcellfill(startcell%,voice%,barno%,beatno%,pitch%,amp%,env%,dur%,gliss%,inf%)
 :
 ENDCASE
 ENDIF
 :
 ENDPROC
 :
 REM****************************************************
 :
 DEF PROCcellfill(cell%,voice%,barno%,beatno%,pitch%,amp%,env%,dur%,gliss%,inf%)
 :
 IF barno% = 999 THEN barno% = array%(cell%,0,voice%) DIV 10^6
 IF beatno% = 999 THEN beatno% = (array%(cell%,0,voice%)DIV 10^3)MOD 10^3
 IF pitch% = 999 THEN pitch% = array%(cell%,0,voice%) MOD 10^3
 IF amp% = 9 THEN amp% = array%(cell%,1,voice%) MOD10
 IF env% = 999 THEN env% = array%(cell%,2,voice%) DIV10^2
 IF dur% = 999 THEN dur% = (array%(cell%,1,voice%) DIV10) MOD 10^3 ELSE PROCconvertdur
 IF gliss% = 99 THEN gliss% = array%(cell%,1,voice%) DIV10^4
 IF inf% = 99 THEN inf% = array%(cell%,2,voice%) MOD 10^2
 :
 array%(cell%,0,voice%) = (barno%*10^6) + (beatno%*10^3) + pitch%
 array%(cell%,1,voice%) = (gliss%*10^4)+(dur%*10)+amp%
 array%(cell%,2,voice%) = (env%*10^2)+inf%
 :
 IF shunt$="Y" THEN numusedcells%(voice%) += 1
 :
 ENDPROC
 :
 REM******************************************************
 :
 DEF PROCshuntright(startcell%)
 :
  FOR tier% = 0 TO 2
   FOR count% = (numusedcells%(voice%)) TO (startcell%+1) STEP -1
    array%(count%,tier%,voice%) = array%((count%-1),tier%,voice%)
   NEXT
  NEXT
 :
 ENDPROC
 :
 REM*********************************************************
 :
 DEF PROCsearch(newvalue%)
 :
 startcell% = -1
 distance% = numusedcells%(voice%)/2
 cellnum% = distance%
 :
 REPEAT
 :
 :
  IF newvalue% = (array%(cellnum%,0,voice%)) DIV 10^3 THEN
   startcell% = cellnum% : REM this ALTERS, rather than adds, a note
   shunt$ = "N"
  ENDIF
 :
  IF cellnum% > 0 THEN
 :
  IF newvalue% = (array%(cellnum%+1,0,voice%)) DIV 10^3 THEN
   startcell% = cellnum%+1 : REM this ALTERS too
   shunt$ = "N"
  ENDIF
 :
 :
  IF newvalue% = (array%(cellnum%-1,0,voice%)) DIV 10^3 THEN
   startcell% = cellnum%-1 : REM this ALTERS too
   shunt$ = "N"
  ENDIF
  :
  IF newvalue% > (array%(cellnum%,0,voice%) DIV 10^3) AND newvalue% <              (array%(cellnum%+1,0,voice%) DIV 10^3) THEN
   startcell% = (cellnum%+1) : REM newvalue immediately to right of cellnum
   shunt$ = "Y"
  ENDIF
  :
  :
  IF newvalue% < (array%(cellnum%,0,voice%) DIV 10^3) AND newvalue% >                (array%(cellnum%-1,0,voice%) DIV 10^3) THEN
   startcell% = cellnum% : REM immediately to left
   shunt$ = "Y"
  ENDIF
  :
  :
  IF newvalue% > (array%(cellnum%+1,0,voice%) DIV 10^3) THEN
   IF distance% = 1 THEN distance% = 2
  distance% = distance%/2
  cellnum% = cellnum% + distance%
  ENDIF
  :
  :
  IF newvalue% < (array%(cellnum%-1,0,voice%) DIV 10^3) THEN
   IF distance% = 1 THEN distance% = 2
  distance% = distance%/2
  cellnum% = cellnum% - distance%
  ENDIF
 ENDIF
  :
  :
 UNTIL startcell% > -1
 :
 ENDPROC
 :
 REM***************************************************
 :
 DEF PROCplay
 :
 waveload$ = "notdone"
 :
 BEATS 960 : REM 2/4 bars, 480 each crotchet
  tic%() = 0
  tun%() = 0
 :
 IF play$ = "play" THEN
IF easiermenus$ = "n" THEN PROCwindow(20,69,60,55) ELSE PROCwindow(20,69,60,42)
 CLS
 INPUT'" Starting at bar "startingbar%
 INPUT'"             beat "beats%
 PROCalterbeats : startbeat% = beats%
 INPUT '" and ending at bar "endbar%
 INPUT'" How many voices "nvoices%
 ENDIF
 :
 :
 FOR count% = 1 TO nvoices%
 IF play$ = "play" THEN
  PRINT'" voice number ";count%;" is which voice number"
  INPUT vnumber%
  playvoices%(count%) = vnumber%
 ELSE vnumber% = playvoices%(count%)
 ENDIF
:
IF usebeep$ = "n" THEN
  CASE count% OF
   WHEN 1 :
 CASE waveforms$(vnumber%) OF
  WHEN "WaveSynth-Beep" : *CHANNELVOICE 1 WaveSynth-Beep
  WHEN "StringLib-Soft" : *CHANNELVOICE 1 StringLib-Soft
  WHEN "StringLib-Pluck" : *CHANNELVOICE 1 StringLib-Pluck
  WHEN "StringLib-Steel" : *CHANNELVOICE 1 StringLib-Steel
  WHEN "StringLib-Hard" : *CHANNELVOICE 1 StringLib-Hard
  WHEN "Percussion-Soft" : *CHANNELVOICE 1 Percussion-Soft
  WHEN "Percussion-Medium" : *CHANNELVOICE 1 Percussion-Medium
  WHEN "Percussion-Snare" : *CHANNELVOICE 1 Percussion-Snare
  WHEN "Percussion-Noise" : *CHANNELVOICE 1 Percussion-Noise
  WHEN "BassBowAb" : *CHANNELVOICE 1 BassBowAb
    tun%(1) = -1470
  WHEN "AcouBass" : *CHANNELVOICE 1 AcouBass
   tun%(1) = -2731
  WHEN "Vibe" : *CHANNELVOICE 1 Vibe
   tun%(1) = -6912
  WHEN "BugleC" : *CHANNELVOICE 1 BugleC
   tun%(1) = -11008
  WHEN "CornetEb" : *CHANNELVOICE 1 CornetEb
   tun%(1) = -12117
  WHEN "SaxEbBarC" : *CHANNELVOICE 1 SaxEbBarC
   tun%(1) = -2816
  WHEN "SaxBbTenrE" : *CHANNELVOICE 1 SaxBbTenrE
   tun%(1) = -4181
  WHEN "BassoonEb" : *CHANNELVOICE 1 BassoonEb
   tun%(1) = -4011
  WHEN "ClarinetBb" : *CHANNELVOICE 1 ClarinetBb
   tun%(1) = -10325
  WHEN "EngHornGb" : *CHANNELVOICE 1 EngHornGb
   tun%(1) = -8960
  WHEN "MandolinDb" : *CHANNELVOICE 1 MandolinDb
   tun%(1) = -11264
  WHEN "Piano2B" : *CHANNELVOICE 1 Piano2B
   tun%(1) = -2475
  WHEN "ClarVibEb" : *CHANNELVOICE 1 ClarVibEb
   tun%(1) = -7850
  WHEN "GtrDobroB" : *CHANNELVOICE 1 GtrDobroB
   tun%(1) = -6485
  WHEN "RecorderGb" : *CHANNELVOICE 1 RecorderGb
   tun%(1) = -13056
  WHEN "FlugelHnEb" : *CHANNELVOICE 1 FlugelHnEb
   tun%(1) = -12032
  WHEN "VceMmmGb23" : *CHANNELVOICE 1 VceMmmGb23
   tun%(1) = -853
  WHEN "VceMOooGb3" : *CHANNELVOICE 1 VceMOooGb3
   tun%(1) = -4843
  WHEN "VceFemAahC" : *CHANNELVOICE 1 VceFemAahC
   tun%(1) = -10948
  WHEN "VceFMmmGb4" : *CHANNELVOICE 1 VceFMmmGb4
   tun%(1) = -8918
  WHEN "Bass" : *CHANNELVOICE 1 Bass
   tun%(1) = 0
  WHEN "ChurchBell" : *CHANNELVOICE 1 ChurchBell
   tun%(1) = -2731
  WHEN "mysound" : *CHANNELVOICE 1 mysound
    tun%(1) = 0
  WHEN "GuiroFast" : *CHANNELVOICE 1 GuiroFast
   tun%(1) = -4000
  WHEN "Clave" : *CHANNELVOICE 1 Clave
   tun%(1) = -8096
  WHEN "CowBell" : *CHANNELVOICE 1 CowBell
   tun%(1) = -5707
  WHEN "CymbRideHd" : *CHANNELVOICE 1 CymbRideHd
   tun%(1) = -8096
WHEN "AcGuitar1" : *CHANNELVOICE 1 AcGuitar1
   tun%(1) = -7072
WHEN "CongaHi" : *CHANNELVOICE 1 CongaHi
   tun%(1) = -4000
WHEN "DrumExplo" : *CHANNELVOICE 1 DrumExplo
   tun%(1) = -4000
WHEN "ElecTom1" : *CHANNELVOICE 1 ElecTom1
   tun%(1) = -8096
WHEN "Harp1" : *CHANNELVOICE 1 Harp1
   tun%(1) = -10997
WHEN "Harpsi" : *CHANNELVOICE 1 Harpsi
   tun%(1) = -6901
WHEN "HiString" : *CHANNELVOICE 1 HiString
   tun%(1) = -10997
WHEN "HonkyPiano" : *CHANNELVOICE 1 HonkyPiano
   tun%(1) = -6901
WHEN "JapFlute" : *CHANNELVOICE 1 JapFlute
   tun%(1) = -10997
WHEN "JazzOrgan" : *CHANNELVOICE 1 JazzOrgan
   tun%(1) = -10997
WHEN "MidStrings" : *CHANNELVOICE 1 MidStrings
   tun%(1) = -6901
WHEN "NoteArp1" : *CHANNELVOICE 1 NoteArp1
   tun%(1) = -4000
WHEN "SnareEcho" : *CHANNELVOICE 1 SnareEcho
   tun%(1) = -4341
WHEN "TablaHi" : *CHANNELVOICE 1 TablaHi
   tun%(1) = -7669
WHEN "Timpani" : *CHANNELVOICE 1 Timpani
   tun%(1) = -928
WHEN "Tomtom1" : *CHANNELVOICE 1 Tomtom1
   tun%(1) = -5365
WHEN "Trombone1" : *CHANNELVOICE 1 Trombone1
   tun%(1) = -6901
WHEN "Trumpet" : *CHANNELVOICE 1 Trumpet
   tun%(1) = -10997
WHEN "Xylophone" : *CHANNELVOICE 1 Xylophone
   tun%(1) = -6901
WHEN "AcouGtr2B" : *CHANNELVOICE 1 AcouGtr2B
   tun%(1) = -6560
WHEN "AcuBassAb1" : *CHANNELVOICE 1 AcuBassAb1
   tun%(1) = -1610
WHEN "BagPipeG" : *CHANNELVOICE 1 BagPipeG
   tun%(1) = -9291
WHEN "BanjoChdBb" : *CHANNELVOICE 1 BanjoChdBb
   tun%(1) = -4000
WHEN "BazookiE" : *CHANNELVOICE 1 BazookiE
   tun%(1) = -8267
WHEN "BellC" : *CHANNELVOICE 1 BellC
   tun%(1) = -10997
WHEN "BrassEns1B" : *CHANNELVOICE 1 BrassEns1B
   tun%(1) = -6560
WHEN "ClavichdBb" : *CHANNELVOICE 1 ClavichdBb
   tun%(1) = -10315
WHEN "ClavinetBb" : *CHANNELVOICE 1 ClavinetBb
   tun%(1) = -6219
WHEN "CornetEb" : *CHANNELVOICE 1 CornetEb
   tun%(1) = -4000
WHEN "EnsWodAb45" : *CHANNELVOICE 1 EnsWodAb45
   tun%(1) = -9632
WHEN "EnsWodGb12" : *CHANNELVOICE 1 EnsWodGb12
   tun%(1) = -4853
WHEN "Glock2Ab5" : *CHANNELVOICE 1 Glock2Ab5
   tun%(1) = -9632
WHEN "GtMelobarC" : *CHANNELVOICE 1 GtMelobarC
   tun%(1) = -6901
WHEN "GtWashbnBb" : *CHANNELVOICE 1 GtWashbnBb
   tun%(1) = -6219
WHEN "HarmonicaE" : *CHANNELVOICE 1 HarmonicaE
   tun%(1) = -4171
WHEN "Jew'sHarpA" : *CHANNELVOICE 1 Jew'sHarpA
   tun%(1) = -6219
WHEN "MusetteB" : *CHANNELVOICE 1 MusetteB
   tun%(1) = -10656
WHEN "OboeGb" : *CHANNELVOICE 1 OboeGb
   tun%(1) = -13131
WHEN "OrchHit2B" : *CHANNELVOICE 1 OrchHit2B
   tun%(1) = -5451
WHEN "OrcSusBb23" : *CHANNELVOICE 1 OrcSusBb23
   tun%(1) = -6304
WHEN "PiccoloE" : *CHANNELVOICE 1 PiccoloE
   tun%(1) = -16544
WHEN "SaxSoprnoE" : *CHANNELVOICE 1 SaxSoprnoE
   tun%(1) = -12448
WHEN "StrngThkBb" : *CHANNELVOICE 1 StrngThkBb
   tun%(1) = -5792
WHEN "TubaGb" : *CHANNELVOICE 1 TubaGb
   tun%(1) = -929
WHEN "BassDrum" : *CHANNELVOICE 1 BassDrum
   tun%(1) = -4000
WHEN "HiHat" : *CHANNELVOICE 1 HiHat
   tun%(1) = -4000
WHEN "OrcHit" : *CHANNELVOICE 1 OrcHit
   tun%(1) = -4085
WHEN "Piano" : *CHANNELVOICE 1 Piano
   tun%(1) = -4171
WHEN "Sax" : *CHANNELVOICE 1 Sax
   tun%(1) = -4085
WHEN "Snare" : *CHANNELVOICE 1 Snare
   tun%(1) = -8096
WHEN "Choir1" : *CHANNELVOICE 1 Choir1
   tun%(1) = -6901
WHEN "ChurOrgan" : *CHANNELVOICE 1 ChurOrgan
   tun%(1) = -6901
WHEN "Opera" : *CHANNELVOICE 1 Opera
   tun%(1) = -13387
WHEN "OrchChoir" : *CHANNELVOICE 1 OrchChoir
   tun%(1) = -6133
WHEN "OrganHit" : *CHANNELVOICE 1 OrganHit
   tun%(1) = -5024
WHEN "AgogoAfric" : *CHANNELVOICE 1 AgogoAfric
   tun%(1) = -6219
WHEN "AgogoBrazi" : *CHANNELVOICE 1 AgogoBrazi
   tun%(1) = -10997
WHEN "AgogoWood" : *CHANNELVOICE 1 AgogoWood
   tun%(1) = -13728
WHEN "BDGatedRev" : *CHANNELVOICE 1 BDGatedRev
   tun%(1) = -5877
WHEN "BDMarching" : *CHANNELVOICE 1 BDMarching
   tun%(1) = -8608
WHEN "BDPiloMute" : *CHANNELVOICE 1 BDPiloMute
   tun%(1) = -7072
WHEN "Cabasa" : *CHANNELVOICE 1 Cabasa
   tun%(1) = -7072
WHEN "Cachichi1" : *CHANNELVOICE 1 Cachichi1
   tun%(1) = -4000
WHEN "CachichiTr" : *CHANNELVOICE 1 CachichiTr
   tun%(1) = -8096
WHEN "Castanets" : *CHANNELVOICE 1 Castanets
   tun%(1) = -4000
WHEN "CongaMid" : *CHANNELVOICE 1 CongaMid
   tun%(1) = -4171
WHEN "CongaSmCl" : *CHANNELVOICE 1 CongaSmCl
   tun%(1) = -4683
WHEN "CymbalCrsh" : *CHANNELVOICE 1 CymbalCrsh
   tun%(1) = -4000
WHEN "CymRideBel" : *CHANNELVOICE 1 CymRideBel
   tun%(1) = -16288
WHEN "CymRStRoll" : *CHANNELVOICE 1 CymRStRoll
   tun%(1) = -6389
WHEN "CymSplshCa" : *CHANNELVOICE 1 CymSplshCa
   tun%(1) = -9120
WHEN "Flexitone" : *CHANNELVOICE 1 Flexitone
   tun%(1) = -8096
WHEN "GongSoft" : *CHANNELVOICE 1 GongSoft
   tun%(1) = -5365
WHEN "Gonza1" : *CHANNELVOICE 1 Gonza1
   tun%(1) = -12192
WHEN "GuiroSlow" : *CHANNELVOICE 1 GuiroSlow
   tun%(1) = -6048
WHEN "HandClaps" : *CHANNELVOICE 1 HandClaps
   tun%(1) = -4000
WHEN "HiHatFoot" : *CHANNELVOICE 1 HiHatFoot
   tun%(1) = -6389
WHEN "Maracas1" : *CHANNELVOICE 1 Maracas1
   tun%(1) = -8096
WHEN "MarimbaSB3" : *CHANNELVOICE 1 MarimbaSB3
   tun%(1) = -4000
WHEN "Ratchet" : *CHANNELVOICE 1 Ratchet
   tun%(1) = -6731
WHEN "RotoTomRev" : *CHANNELVOICE 1 RotoTomRev
   tun%(1) = -6133
WHEN "SimmonsBD1" : *CHANNELVOICE 1 SimmonsBD1
   tun%(1) = -8096
WHEN "SimmonsSn1" : *CHANNELVOICE 1 SimmonsSn1
   tun%(1) = -5707
WHEN "SleighBell" : *CHANNELVOICE 1 SleighBell
   tun%(1) = -4000
WHEN "SuperGong" : *CHANNELVOICE 1 SuperGong
   tun%(1) = -4341
WHEN "SynthSnare" : *CHANNELVOICE 1 SynthSnare
   tun%(1) = -4000
WHEN "SynTom" : *CHANNELVOICE 1 SynTom
   tun%(1) = -9120
WHEN "TimpCresBb" : *CHANNELVOICE 1 TimpCresBb
   tun%(1) = -5962
WHEN "TimpLowBb" : *CHANNELVOICE 1 TimpLowBb
   tun%(1) = -5707
WHEN "TimpRollEb" : *CHANNELVOICE 1 TimpRollEb
   tun%(1) = -4000
WHEN "TomRoll" : *CHANNELVOICE 1 TomRoll
   tun%(1) = -4000
WHEN "ToyHooter" : *CHANNELVOICE 1 ToyHooter
   tun%(1) = -9717
WHEN "ToyWhistle" : *CHANNELVOICE 1 ToyWhistle
   tun%(1) = -4000
 ENDCASE
:
   WHEN 2 :
 CASE waveforms$(vnumber%) OF
  WHEN "WaveSynth-Beep" : *CHANNELVOICE 2 WaveSynth-Beep
  WHEN "StringLib-Soft" : *CHANNELVOICE 2 StringLib-Soft
  WHEN "StringLib-Pluck" : *CHANNELVOICE 2 StringLib-Pluck
  WHEN "StringLib-Steel" : *CHANNELVOICE 2 StringLib-Steel
  WHEN "StringLib-Hard" : *CHANNELVOICE 2 StringLib-Hard
  WHEN "Percussion-Soft" : *CHANNELVOICE 2 Percussion-Soft
  WHEN "Percussion-Medium" : *CHANNELVOICE 2 Percussion-Medium
  WHEN "Percussion-Snare" : *CHANNELVOICE 2 Percussion-Snare
  WHEN "Percussion-Noise" : *CHANNELVOICE 2 Percussion-Noise
  WHEN "BassBowAb" : *CHANNELVOICE 2 BassBowAb
    tun%(2) = -1470
  WHEN "AcouBass" : *CHANNELVOICE 2 AcouBass
   tun%(2) = -2731
  WHEN "Vibe" : *CHANNELVOICE 2 Vibe
   tun%(2) = -6912
  WHEN "BugleC" : *CHANNELVOICE 2 BugleC
   tun%(2) = -11008
  WHEN "CornetEb" : *CHANNELVOICE 2 CornetEb
   tun%(2) = -12117
  WHEN "SaxEbBarC" : *CHANNELVOICE 2 SaxEbBarC
   tun%(2) = -2816
  WHEN "SaxBbTenrE" : *CHANNELVOICE 2 SaxBbTenrE
   tun%(2) = -4181
  WHEN "BassoonEb" : *CHANNELVOICE 2 BassoonEb
   tun%(2) = -4011
  WHEN "ClarinetBb" : *CHANNELVOICE 2 ClarinetBb
   tun%(2) = -10325
  WHEN "EngHornGb" : *CHANNELVOICE 2 EngHornGb
   tun%(2) = -8960
  WHEN "MandolinDb" : *CHANNELVOICE 2 MandolinDb
   tun%(2) = -11264
  WHEN "Piano2B" : *CHANNELVOICE 2 Piano2B
   tun%(2) = -2475
  WHEN "ClarVibEb" : *CHANNELVOICE 2 ClarVibEb
   tun%(2) = -7850
  WHEN "GtrDobroB" : *CHANNELVOICE 2 GtrDobroB
   tun%(2) = -6485
  WHEN "RecorderGb" : *CHANNELVOICE 2 RecorderGb
   tun%(2) = -13056
  WHEN "FlugelHnEb" : *CHANNELVOICE 2 FlugelHnEb
   tun%(2) = -12032
  WHEN "VceMmmGb23" : *CHANNELVOICE 2 VceMmmGb23
   tun%(2) = -853
  WHEN "VceMOooGb3" : *CHANNELVOICE 2 VceMOooGb3
   tun%(2) = -4843
  WHEN "VceFemAahC" : *CHANNELVOICE 2 VceFemAahC
   tun%(2) = -10948
  WHEN "VceFMmmGb4" : *CHANNELVOICE 2 VceFMmmGb4
   tun%(2) = -8918
  WHEN "Bass" : *CHANNELVOICE 2 Bass
   tun%(2) = 0
  WHEN "ChurchBell" : *CHANNELVOICE 2 ChurchBell
   tun%(2) = -2731
  WHEN "mysound" : *CHANNELVOICE 2 mysound
    tun%(2) = 0
  WHEN "GuiroFast" : *CHANNELVOICE 2 GuiroFast
   tun%(2) = -4000
  WHEN "Clave" : *CHANNELVOICE 2 Clave
   tun%(2) = -8096
  WHEN "CowBell" : *CHANNELVOICE 2 CowBell
   tun%(2) = -5707
  WHEN "CymbRideHd" : *CHANNELVOICE 2 CymbRideHd
   tun%(2) = -8096
WHEN "AcGuitar1" : *CHANNELVOICE 2 AcGuitar1
   tun%(2) = -7072
WHEN "CongaHi" : *CHANNELVOICE 2 CongaHi
   tun%(2) = -4000
WHEN "DrumExplo" : *CHANNELVOICE 2 DrumExplo
   tun%(2) = -4000
WHEN "ElecTom1" : *CHANNELVOICE 2 ElecTom1
   tun%(2) = -8096
WHEN "Harp1" : *CHANNELVOICE 2 Harp1
   tun%(2) = -10997
WHEN "Harpsi" : *CHANNELVOICE 2 Harpsi
   tun%(2) = -6901
WHEN "HiString" : *CHANNELVOICE 2 HiString
   tun%(2) = -10997
WHEN "HonkyPiano" : *CHANNELVOICE 2 HonkyPiano
   tun%(2) = -6901
WHEN "JapFlute" : *CHANNELVOICE 2 JapFlute
   tun%(2) = -10997
WHEN "JazzOrgan" : *CHANNELVOICE 2 JazzOrgan
   tun%(2) = -10997
WHEN "MidStrings" : *CHANNELVOICE 2 MidStrings
   tun%(2) = -6901
WHEN "NoteArp1" : *CHANNELVOICE 2 NoteArp1
   tun%(2) = -4000
WHEN "SnareEcho" : *CHANNELVOICE 2 SnareEcho
   tun%(2) = -4341
WHEN "TablaHi" : *CHANNELVOICE 2 TablaHi
   tun%(2) = -7669
WHEN "Timpani" : *CHANNELVOICE 2 Timpani
   tun%(2) = -928
WHEN "Tomtom1" : *CHANNELVOICE 2 Tomtom1
   tun%(2) = -5365
WHEN "Trombone1" : *CHANNELVOICE 2 Trombone1
   tun%(2) = -6901
WHEN "Trumpet" : *CHANNELVOICE 2 Trumpet
   tun%(2) = -10997
WHEN "Xylophone" : *CHANNELVOICE 2 Xylophone
   tun%(2) = -6901
WHEN "AcouGtr2B" : *CHANNELVOICE 2 AcouGtr2B
   tun%(2) = -6560
WHEN "AcuBassAb1" : *CHANNELVOICE 2 AcuBassAb1
   tun%(2) = -1610
WHEN "BagPipeG" : *CHANNELVOICE 2 BagPipeG
   tun%(2) = -9291
WHEN "BanjoChdBb" : *CHANNELVOICE 2 BanjoChdBb
   tun%(2) = -4000
WHEN "BazookiE" : *CHANNELVOICE 2 BazookiE
   tun%(2) = -8267
WHEN "BellC" : *CHANNELVOICE 2 BellC
   tun%(2) = -10997
WHEN "BrassEns1B" : *CHANNELVOICE 2 BrassEns1B
   tun%(2) = -6560
WHEN "ClavichdBb" : *CHANNELVOICE 2 ClavichdBb
   tun%(2) = -10315
WHEN "ClavinetBb" : *CHANNELVOICE 2 ClavinetBb
   tun%(2) = -6219
WHEN "CornetEb" : *CHANNELVOICE 2 CornetEb
   tun%(2) = -4000
WHEN "EnsWodAb45" : *CHANNELVOICE 2 EnsWodAb45
   tun%(2) = -9632
WHEN "EnsWodGb12" : *CHANNELVOICE 2 EnsWodGb12
   tun%(2) = -4853
WHEN "Glock2Ab5" : *CHANNELVOICE 2 Glock2Ab5
   tun%(2) = -9632
WHEN "GtMelobarC" : *CHANNELVOICE 2 GtMelobarC
   tun%(2) = -6901
WHEN "GtWashbnBb" : *CHANNELVOICE 2 GtWashbnBb
   tun%(2) = -6219
WHEN "HarmonicaE" : *CHANNELVOICE 2 HarmonicaE
   tun%(2) = -4171
WHEN "Jew'sHarpA" : *CHANNELVOICE 2 Jew'sHarpA
   tun%(2) = -6219
WHEN "MusetteB" : *CHANNELVOICE 2 MusetteB
   tun%(2) = -10656
WHEN "OboeGb" : *CHANNELVOICE 2 OboeGb
   tun%(2) = -13131
WHEN "OrchHit2B" : *CHANNELVOICE 2 OrchHit2B
   tun%(2) = -5451
WHEN "OrcSusBb23" : *CHANNELVOICE 2 OrcSusBb23
   tun%(2) = -6304
WHEN "PiccoloE" : *CHANNELVOICE 2 PiccoloE
   tun%(2) = -16544
WHEN "SaxSoprnoE" : *CHANNELVOICE 2 SaxSoprnoE
   tun%(2) = -12448
WHEN "StrngThkBb" : *CHANNELVOICE 2 StrngThkBb
   tun%(2) = -5792
WHEN "TubaGb" : *CHANNELVOICE 2 TubaGb
   tun%(2) = -929
WHEN "BassDrum" : *CHANNELVOICE 2 BassDrum
   tun%(2) = -4000
WHEN "HiHat" : *CHANNELVOICE 2 HiHat
   tun%(2) = -4000
WHEN "OrcHit" : *CHANNELVOICE 2 OrcHit
   tun%(2) = -4085
WHEN "Piano" : *CHANNELVOICE 2 Piano
   tun%(2) = -4171
WHEN "Sax" : *CHANNELVOICE 2 Sax
   tun%(2) = -4085
WHEN "Snare" : *CHANNELVOICE 2 Snare
   tun%(2) = -8096
WHEN "Choir1" : *CHANNELVOICE 2 Choir1
   tun%(2) = -6901
WHEN "ChurOrgan" : *CHANNELVOICE 2 ChurOrgan
   tun%(2) = -6901
WHEN "Opera" : *CHANNELVOICE 2 Opera
   tun%(2) = -13387
WHEN "OrchChoir" : *CHANNELVOICE 2 OrchChoir
   tun%(2) = -6133
WHEN "OrganHit" : *CHANNELVOICE 2 OrganHit
   tun%(2) = -5024
WHEN "AgogoAfric" : *CHANNELVOICE 2 AgogoAfric
   tun%(2) = -6219
WHEN "AgogoBrazi" : *CHANNELVOICE 2 AgogoBrazi
   tun%(2) = -10997
WHEN "AgogoWood" : *CHANNELVOICE 2 AgogoWood
   tun%(2) = -13728
WHEN "BDGatedRev" : *CHANNELVOICE 2 BDGatedRev
   tun%(2) = -5877
WHEN "BDMarching" : *CHANNELVOICE 2 BDMarching
   tun%(2) = -8608
WHEN "BDPiloMute" : *CHANNELVOICE 2 BDPiloMute
   tun%(2) = -7072
WHEN "Cabasa" : *CHANNELVOICE 2 Cabasa
   tun%(2) = -7072
WHEN "Cachichi1" : *CHANNELVOICE 2 Cachichi1
   tun%(2) = -4000
WHEN "CachichiTr" : *CHANNELVOICE 2 CachichiTr
   tun%(2) = -8096
WHEN "Castanets" : *CHANNELVOICE 2 Castanets
   tun%(2) = -4000
WHEN "CongaMid" : *CHANNELVOICE 2 CongaMid
   tun%(2) = -4171
WHEN "CongaSmCl" : *CHANNELVOICE 2 CongaSmCl
   tun%(2) = -4683
WHEN "CymbalCrsh" : *CHANNELVOICE 2 CymbalCrsh
   tun%(2) = -4000
WHEN "CymRideBel" : *CHANNELVOICE 2 CymRideBel
   tun%(2) = -16288
WHEN "CymRStRoll" : *CHANNELVOICE 2 CymRStRoll
   tun%(2) = -6389
WHEN "CymSplshCa" : *CHANNELVOICE 2 CymSplshCa
   tun%(2) = -9120
WHEN "Flexitone" : *CHANNELVOICE 2 Flexitone
   tun%(2) = -8096
WHEN "GongSoft" : *CHANNELVOICE 2 GongSoft
   tun%(2) = -5365
WHEN "Gonza1" : *CHANNELVOICE 2 Gonza1
   tun%(2) = -12192
WHEN "GuiroSlow" : *CHANNELVOICE 2 GuiroSlow
   tun%(2) = -6048
WHEN "HandClaps" : *CHANNELVOICE 2 HandClaps
   tun%(2) = -4000
WHEN "HiHatFoot" : *CHANNELVOICE 2 HiHatFoot
   tun%(2) = -6389
WHEN "Maracas1" : *CHANNELVOICE 2 Maracas1
   tun%(2) = -8096
WHEN "MarimbaSB3" : *CHANNELVOICE 2 MarimbaSB3
   tun%(2) = -4000
WHEN "Ratchet" : *CHANNELVOICE 2 Ratchet
   tun%(2) = -6731
WHEN "RotoTomRev" : *CHANNELVOICE 2 RotoTomRev
   tun%(2) = -6133
WHEN "SimmonsBD1" : *CHANNELVOICE 2 SimmonsBD1
   tun%(2) = -8096
WHEN "SimmonsSn1" : *CHANNELVOICE 2 SimmonsSn1
   tun%(2) = -5707
WHEN "SleighBell" : *CHANNELVOICE 2 SleighBell
   tun%(2) = -4000
WHEN "SuperGong" : *CHANNELVOICE 2 SuperGong
   tun%(2) = -4341
WHEN "SynthSnare" : *CHANNELVOICE 2 SynthSnare
   tun%(2) = -4000
WHEN "SynTom" : *CHANNELVOICE 2 SynTom
   tun%(2) = -9120
WHEN "TimpCresBb" : *CHANNELVOICE 2 TimpCresBb
   tun%(2) = -5962
WHEN "TimpLowBb" : *CHANNELVOICE 2 TimpLowBb
   tun%(2) = -5707
WHEN "TimpRollEb" : *CHANNELVOICE 2 TimpRollEb
   tun%(2) = -4000
WHEN "TomRoll" : *CHANNELVOICE 2 TomRoll
   tun%(2) = -4000
WHEN "ToyHooter" : *CHANNELVOICE 2 ToyHooter
   tun%(2) = -9717
WHEN "ToyWhistle" : *CHANNELVOICE 2 ToyWhistle
   tun%(2) = -4000
  ENDCASE


 WHEN 3 :
 CASE waveforms$(vnumber%) OF
  WHEN "WaveSynth-Beep" : *CHANNELVOICE 3 WaveSynth-Beep
  WHEN "StringLib-Soft" : *CHANNELVOICE 3 StringLib-Soft
  WHEN "StringLib-Pluck" : *CHANNELVOICE 3 StringLib-Pluck
  WHEN "StringLib-Steel" : *CHANNELVOICE 3 StringLib-Steel
  WHEN "StringLib-Hard" : *CHANNELVOICE 3 StringLib-Hard
  WHEN "Percussion-Soft" : *CHANNELVOICE 3 Percussion-Soft
  WHEN "Percussion-Medium" : *CHANNELVOICE 3 Percussion-Medium
  WHEN "Percussion-Snare" : *CHANNELVOICE 3 Percussion-Snare
  WHEN "Percussion-Noise" : *CHANNELVOICE 3 Percussion-Noise
  WHEN "BassBowAb" : *CHANNELVOICE 3 BassBowAb
    tun%(3) = -1470
  WHEN "AcouBass" : *CHANNELVOICE 3 AcouBass
   tun%(3) = -2731
  WHEN "Vibe" : *CHANNELVOICE 3 Vibe
   tun%(3) = -6912
  WHEN "BugleC" : *CHANNELVOICE 3 BugleC
   tun%(3) = -11008
  WHEN "CornetEb" : *CHANNELVOICE 3 CornetEb
   tun%(3) = -12117
  WHEN "SaxEbBarC" : *CHANNELVOICE 3 SaxEbBarC
   tun%(3) = -2816
  WHEN "SaxBbTenrE" : *CHANNELVOICE 3 SaxBbTenrE
   tun%(3) = -4181
  WHEN "BassoonEb" : *CHANNELVOICE 3 BassoonEb
   tun%(3) = -4011
  WHEN "ClarinetBb" : *CHANNELVOICE 3 ClarinetBb
   tun%(3) = -10325
  WHEN "EngHornGb" : *CHANNELVOICE 3 EngHornGb
   tun%(3) = -8960
  WHEN "MandolinDb" : *CHANNELVOICE 3 MandolinDb
   tun%(3) = -11264
  WHEN "Piano2B" : *CHANNELVOICE 3 Piano2B
   tun%(3) = -2475
  WHEN "ClarVibEb" : *CHANNELVOICE 3 ClarVibEb
   tun%(3) = -7850
  WHEN "GtrDobroB" : *CHANNELVOICE 3 GtrDobroB
   tun%(3) = -6485
  WHEN "RecorderGb" : *CHANNELVOICE 3 RecorderGb
   tun%(3) = -13056
  WHEN "FlugelHnEb" : *CHANNELVOICE 3 FlugelHnEb
   tun%(3) = -12032
  WHEN "VceMmmGb23" : *CHANNELVOICE 3 VceMmmGb23
   tun%(3) = -853
  WHEN "VceMOooGb3" : *CHANNELVOICE 3 VceMOooGb3
   tun%(3) = -4843
  WHEN "VceFemAahC" : *CHANNELVOICE 3 VceFemAahC
   tun%(3) = -10948
  WHEN "VceFMmmGb4" : *CHANNELVOICE 3 VceFMmmGb4
   tun%(3) = -8918
  WHEN "Bass" : *CHANNELVOICE 3 Bass
   tun%(3) = 0
  WHEN "ChurchBell" : *CHANNELVOICE 3 ChurchBell
   tun%(3) = -2731
  WHEN "mysound" : *CHANNELVOICE 3 mysound
    tun%(3) = 0
  WHEN "GuiroFast" : *CHANNELVOICE 3 GuiroFast
   tun%(3) = -4000
  WHEN "Clave" : *CHANNELVOICE 3 Clave
   tun%(3) = -8096
  WHEN "CowBell" : *CHANNELVOICE 3 CowBell
   tun%(3) = -5707
  WHEN "CymbRideHd" : *CHANNELVOICE 3 CymbRideHd
   tun%(3) = -8096
WHEN "AcGuitar1" : *CHANNELVOICE 3 AcGuitar1
   tun%(3) = -7072
WHEN "CongaHi" : *CHANNELVOICE 3 CongaHi
   tun%(3) = -4000
WHEN "DrumExplo" : *CHANNELVOICE 3 DrumExplo
   tun%(3) = -4000
WHEN "ElecTom1" : *CHANNELVOICE 3 ElecTom1
   tun%(3) = -8096
WHEN "Harp1" : *CHANNELVOICE 3 Harp1
   tun%(3) = -10997
WHEN "Harpsi" : *CHANNELVOICE 3 Harpsi
   tun%(3) = -6901
WHEN "HiString" : *CHANNELVOICE 3 HiString
   tun%(3) = -10997
WHEN "HonkyPiano" : *CHANNELVOICE 3 HonkyPiano
   tun%(3) = -6901
WHEN "JapFlute" : *CHANNELVOICE 3 JapFlute
   tun%(3) = -10997
WHEN "JazzOrgan" : *CHANNELVOICE 3 JazzOrgan
   tun%(3) = -10997
WHEN "MidStrings" : *CHANNELVOICE 3 MidStrings
   tun%(3) = -6901
WHEN "NoteArp1" : *CHANNELVOICE 3 NoteArp1
   tun%(3) = -4000
WHEN "SnareEcho" : *CHANNELVOICE 3 SnareEcho
   tun%(3) = -4341
WHEN "TablaHi" : *CHANNELVOICE 3 TablaHi
   tun%(3) = -7669
WHEN "Timpani" : *CHANNELVOICE 3 Timpani
   tun%(3) = -928
WHEN "Tomtom1" : *CHANNELVOICE 3 Tomtom1
   tun%(3) = -5365
WHEN "Trombone1" : *CHANNELVOICE 3 Trombone1
   tun%(3) = -6901
WHEN "Trumpet" : *CHANNELVOICE 3 Trumpet
   tun%(3) = -10997
WHEN "Xylophone" : *CHANNELVOICE 3 Xylophone
   tun%(3) = -6901
WHEN "AcouGtr2B" : *CHANNELVOICE 3 AcouGtr2B
   tun%(3) = -6560
WHEN "AcuBassAb1" : *CHANNELVOICE 3 AcuBassAb1
   tun%(3) = -1610
WHEN "BagPipeG" : *CHANNELVOICE 3 BagPipeG
   tun%(3) = -9291
WHEN "BanjoChdBb" : *CHANNELVOICE 3 BanjoChdBb
   tun%(3) = -4000
WHEN "BazookiE" : *CHANNELVOICE 3 BazookiE
   tun%(3) = -8267
WHEN "BellC" : *CHANNELVOICE 3 BellC
   tun%(3) = -10997
WHEN "BrassEns1B" : *CHANNELVOICE 3 BrassEns1B
   tun%(3) = -6560
WHEN "ClavichdBb" : *CHANNELVOICE 3 ClavichdBb
   tun%(3) = -10315
WHEN "ClavinetBb" : *CHANNELVOICE 3 ClavinetBb
   tun%(3) = -6219
WHEN "CornetEb" : *CHANNELVOICE 3 CornetEb
   tun%(3) = -4000
WHEN "EnsWodAb45" : *CHANNELVOICE 3 EnsWodAb45
   tun%(3) = -9632
WHEN "EnsWodGb12" : *CHANNELVOICE 3 EnsWodGb12
   tun%(3) = -4853
WHEN "Glock2Ab5" : *CHANNELVOICE 3 Glock2Ab5
   tun%(3) = -9632
WHEN "GtMelobarC" : *CHANNELVOICE 3 GtMelobarC
   tun%(3) = -6901
WHEN "GtWashbnBb" : *CHANNELVOICE 3 GtWashbnBb
   tun%(3) = -6219
WHEN "HarmonicaE" : *CHANNELVOICE 3 HarmonicaE
   tun%(3) = -4171
WHEN "Jew'sHarpA" : *CHANNELVOICE 3 Jew'sHarpA
   tun%(3) = -6219
WHEN "MusetteB" : *CHANNELVOICE 3 MusetteB
   tun%(3) = -10656
WHEN "OboeGb" : *CHANNELVOICE 3 OboeGb
   tun%(3) = -13131
WHEN "OrchHit2B" : *CHANNELVOICE 3 OrchHit2B
   tun%(3) = -5451
WHEN "OrcSusBb23" : *CHANNELVOICE 3 OrcSusBb23
   tun%(3) = -6304
WHEN "PiccoloE" : *CHANNELVOICE 3 PiccoloE
   tun%(3) = -16544
WHEN "SaxSoprnoE" : *CHANNELVOICE 3 SaxSoprnoE
   tun%(3) = -12448
WHEN "StrngThkBb" : *CHANNELVOICE 3 StrngThkBb
   tun%(3) = -5792
WHEN "TubaGb" : *CHANNELVOICE 3 TubaGb
   tun%(3) = -929
WHEN "BassDrum" : *CHANNELVOICE 3 BassDrum
   tun%(3) = -4000
WHEN "HiHat" : *CHANNELVOICE 3 HiHat
   tun%(3) = -4000
WHEN "OrcHit" : *CHANNELVOICE 3 OrcHit
   tun%(3) = -4085
WHEN "Piano" : *CHANNELVOICE 3 Piano
   tun%(3) = -4171
WHEN "Sax" : *CHANNELVOICE 3 Sax
   tun%(3) = -4085
WHEN "Snare" : *CHANNELVOICE 3 Snare
   tun%(3) = -8096
WHEN "Choir1" : *CHANNELVOICE 3 Choir1
   tun%(3) = -6901
WHEN "ChurOrgan" : *CHANNELVOICE 3 ChurOrgan
   tun%(3) = -6901
WHEN "Opera" : *CHANNELVOICE 3 Opera
   tun%(3) = -13387
WHEN "OrchChoir" : *CHANNELVOICE 3 OrchChoir
   tun%(3) = -6133
WHEN "OrganHit" : *CHANNELVOICE 3 OrganHit
   tun%(3) = -5024
WHEN "AgogoAfric" : *CHANNELVOICE 3 AgogoAfric
   tun%(3) = -6219
WHEN "AgogoBrazi" : *CHANNELVOICE 3 AgogoBrazi
   tun%(3) = -10997
WHEN "AgogoWood" : *CHANNELVOICE 3 AgogoWood
   tun%(3) = -13728
WHEN "BDGatedRev" : *CHANNELVOICE 3 BDGatedRev
   tun%(3) = -5877
WHEN "BDMarching" : *CHANNELVOICE 3 BDMarching
   tun%(3) = -8608
WHEN "BDPiloMute" : *CHANNELVOICE 3 BDPiloMute
   tun%(3) = -7072
WHEN "Cabasa" : *CHANNELVOICE 3 Cabasa
   tun%(3) = -7072
WHEN "Cachichi1" : *CHANNELVOICE 3 Cachichi1
   tun%(3) = -4000
WHEN "CachichiTr" : *CHANNELVOICE 3 CachichiTr
   tun%(3) = -8096
WHEN "Castanets" : *CHANNELVOICE 3 Castanets
   tun%(3) = -4000
WHEN "CongaMid" : *CHANNELVOICE 3 CongaMid
   tun%(3) = -4171
WHEN "CongaSmCl" : *CHANNELVOICE 3 CongaSmCl
   tun%(3) = -4683
WHEN "CymbalCrsh" : *CHANNELVOICE 3 CymbalCrsh
   tun%(3) = -4000
WHEN "CymRideBel" : *CHANNELVOICE 3 CymRideBel
   tun%(3) = -16288
WHEN "CymRStRoll" : *CHANNELVOICE 3 CymRStRoll
   tun%(3) = -6389
WHEN "CymSplshCa" : *CHANNELVOICE 3 CymSplshCa
   tun%(3) = -9120
WHEN "Flexitone" : *CHANNELVOICE 3 Flexitone
   tun%(3) = -8096
WHEN "GongSoft" : *CHANNELVOICE 3 GongSoft
   tun%(3) = -5365
WHEN "Gonza1" : *CHANNELVOICE 3 Gonza1
   tun%(3) = -12192
WHEN "GuiroSlow" : *CHANNELVOICE 3 GuiroSlow
   tun%(3) = -6048
WHEN "HandClaps" : *CHANNELVOICE 3 HandClaps
   tun%(3) = -4000
WHEN "HiHatFoot" : *CHANNELVOICE 3 HiHatFoot
   tun%(3) = -6389
WHEN "Maracas1" : *CHANNELVOICE 3 Maracas1
   tun%(3) = -8096
WHEN "MarimbaSB3" : *CHANNELVOICE 3 MarimbaSB3
   tun%(3) = -4000
WHEN "Ratchet" : *CHANNELVOICE 3 Ratchet
   tun%(3) = -6731
WHEN "RotoTomRev" : *CHANNELVOICE 3 RotoTomRev
   tun%(3) = -6133
WHEN "SimmonsBD1" : *CHANNELVOICE 3 SimmonsBD1
   tun%(3) = -8096
WHEN "SimmonsSn1" : *CHANNELVOICE 3 SimmonsSn1
   tun%(3) = -5707
WHEN "SleighBell" : *CHANNELVOICE 3 SleighBell
   tun%(3) = -4000
WHEN "SuperGong" : *CHANNELVOICE 3 SuperGong
   tun%(3) = -4341
WHEN "SynthSnare" : *CHANNELVOICE 3 SynthSnare
   tun%(3) = -4000
WHEN "SynTom" : *CHANNELVOICE 3 SynTom
   tun%(3) = -9120
WHEN "TimpCresBb" : *CHANNELVOICE 3 TimpCresBb
   tun%(3) = -5962
WHEN "TimpLowBb" : *CHANNELVOICE 3 TimpLowBb
   tun%(3) = -5707
WHEN "TimpRollEb" : *CHANNELVOICE 3 TimpRollEb
   tun%(3) = -4000
WHEN "TomRoll" : *CHANNELVOICE 3 TomRoll
   tun%(3) = -4000
WHEN "ToyHooter" : *CHANNELVOICE 3 ToyHooter
   tun%(3) = -9717
WHEN "ToyWhistle" : *CHANNELVOICE 3 ToyWhistle
   tun%(3) = -4000
 ENDCASE


   WHEN 4 :
 CASE waveforms$(vnumber%) OF
  WHEN "WaveSynth-Beep" : *CHANNELVOICE 4 WaveSynth-Beep
  WHEN "StringLib-Soft" : *CHANNELVOICE 4 StringLib-Soft
  WHEN "StringLib-Pluck" : *CHANNELVOICE 4 StringLib-Pluck
  WHEN "StringLib-Steel" : *CHANNELVOICE 4 StringLib-Steel
  WHEN "StringLib-Hard" : *CHANNELVOICE 4 StringLib-Hard
  WHEN "Percussion-Soft" : *CHANNELVOICE 4 Percussion-Soft
  WHEN "Percussion-Medium" : *CHANNELVOICE 4 Percussion-Medium
  WHEN "Percussion-Snare" : *CHANNELVOICE 4 Percussion-Snare
  WHEN "Percussion-Noise" : *CHANNELVOICE 4 Percussion-Noise
  WHEN "BassBowAb" : *CHANNELVOICE 4 BassBowAb
    tun%(4) = -1470
  WHEN "AcouBass" : *CHANNELVOICE 4 AcouBass
   tun%(4) = -2731
  WHEN "Vibe" : *CHANNELVOICE 4 Vibe
   tun%(4) = -6912
  WHEN "BugleC" : *CHANNELVOICE 4 BugleC
   tun%(4) = -11008
  WHEN "CornetEb" : *CHANNELVOICE 4 CornetEb
   tun%(4) = -12117
  WHEN "SaxEbBarC" : *CHANNELVOICE 4 SaxEbBarC
   tun%(4) = -2816
  WHEN "SaxBbTenrE" : *CHANNELVOICE 4 SaxBbTenrE
   tun%(4) = -4181
  WHEN "BassoonEb" : *CHANNELVOICE 4 BassoonEb
   tun%(4) = -4011
  WHEN "ClarinetBb" : *CHANNELVOICE 4 ClarinetBb
   tun%(4) = -10325
  WHEN "EngHornGb" : *CHANNELVOICE 4 EngHornGb
   tun%(4) = -8960
  WHEN "MandolinDb" : *CHANNELVOICE 4 MandolinDb
   tun%(4) = -11264
  WHEN "Piano2B" : *CHANNELVOICE 4 Piano2B
   tun%(4) = -2475
  WHEN "ClarVibEb" : *CHANNELVOICE 4 ClarVibEb
   tun%(4) = -7850
  WHEN "GtrDobroB" : *CHANNELVOICE 4 GtrDobroB
   tun%(4) = -6485
  WHEN "RecorderGb" : *CHANNELVOICE 4 RecorderGb
   tun%(4) = -13056
  WHEN "FlugelHnEb" : *CHANNELVOICE 4 FlugelHnEb
   tun%(4) = -12032
  WHEN "VceMmmGb23" : *CHANNELVOICE 4 VceMmmGb23
   tun%(4) = -853
  WHEN "VceMOooGb3" : *CHANNELVOICE 4 VceMOooGb3
   tun%(4) = -4843
  WHEN "VceFemAahC" : *CHANNELVOICE 4 VceFemAahC
   tun%(4) = -10948
  WHEN "VceFMmmGb4" : *CHANNELVOICE 4 VceFMmmGb4
   tun%(4) = -8918
  WHEN "Bass" : *CHANNELVOICE 4 Bass
   tun%(4) = 0
  WHEN "ChurchBell" : *CHANNELVOICE 4 ChurchBell
   tun%(4) = -2731
  WHEN "mysound" : *CHANNELVOICE 4 mysound
    tun%(4) = 0
  WHEN "GuiroFast" : *CHANNELVOICE 4 GuiroFast
   tun%(4) = -4000
  WHEN "Clave" : *CHANNELVOICE 4 Clave
   tun%(4) = -8096
  WHEN "CowBell" : *CHANNELVOICE 4 CowBell
   tun%(4) = -5707
  WHEN "CymbRideHd" : *CHANNELVOICE 4 CymbRideHd
   tun%(4) = -8096
WHEN "AcGuitar1" : *CHANNELVOICE 4 AcGuitar1
   tun%(4) = -7072
WHEN "CongaHi" : *CHANNELVOICE 4 CongaHi
   tun%(4) = -4000
WHEN "DrumExplo" : *CHANNELVOICE 4 DrumExplo
   tun%(4) = -4000
WHEN "ElecTom1" : *CHANNELVOICE 4 ElecTom1
   tun%(4) = -8096
WHEN "Harp1" : *CHANNELVOICE 4 Harp1
   tun%(4) = -10997
WHEN "Harpsi" : *CHANNELVOICE 4 Harpsi
   tun%(4) = -6901
WHEN "HiString" : *CHANNELVOICE 4 HiString
   tun%(4) = -10997
WHEN "HonkyPiano" : *CHANNELVOICE 4 HonkyPiano
   tun%(4) = -6901
WHEN "JapFlute" : *CHANNELVOICE 4 JapFlute
   tun%(4) = -10997
WHEN "JazzOrgan" : *CHANNELVOICE 4 JazzOrgan
   tun%(4) = -10997
WHEN "MidStrings" : *CHANNELVOICE 4 MidStrings
   tun%(4) = -6901
WHEN "NoteArp1" : *CHANNELVOICE 4 NoteArp1
   tun%(4) = -4000
WHEN "SnareEcho" : *CHANNELVOICE 4 SnareEcho
   tun%(4) = -4341
WHEN "TablaHi" : *CHANNELVOICE 4 TablaHi
   tun%(4) = -7669
WHEN "Timpani" : *CHANNELVOICE 4 Timpani
   tun%(4) = -928
WHEN "Tomtom1" : *CHANNELVOICE 4 Tomtom1
   tun%(4) = -5365
WHEN "Trombone1" : *CHANNELVOICE 4 Trombone1
   tun%(4) = -6901
WHEN "Trumpet" : *CHANNELVOICE 4 Trumpet
   tun%(4) = -10997
WHEN "Xylophone" : *CHANNELVOICE 4 Xylophone
   tun%(4) = -6901
WHEN "AcouGtr2B" : *CHANNELVOICE 4 AcouGtr2B
   tun%(4) = -6560
WHEN "AcuBassAb1" : *CHANNELVOICE 4 AcuBassAb1
   tun%(4) = -1610
WHEN "BagPipeG" : *CHANNELVOICE 4 BagPipeG
   tun%(4) = -9291
WHEN "BanjoChdBb" : *CHANNELVOICE 4 BanjoChdBb
   tun%(4) = -4000
WHEN "BazookiE" : *CHANNELVOICE 4 BazookiE
   tun%(4) = -8267
WHEN "BellC" : *CHANNELVOICE 4 BellC
   tun%(4) = -10997
WHEN "BrassEns1B" : *CHANNELVOICE 4 BrassEns1B
   tun%(4) = -6560
WHEN "ClavichdBb" : *CHANNELVOICE 4 ClavichdBb
   tun%(4) = -10315
WHEN "ClavinetBb" : *CHANNELVOICE 4 ClavinetBb
   tun%(4) = -6219
WHEN "CornetEb" : *CHANNELVOICE 4 CornetEb
   tun%(4) = -4000
WHEN "EnsWodAb45" : *CHANNELVOICE 4 EnsWodAb45
   tun%(4) = -9632
WHEN "EnsWodGb12" : *CHANNELVOICE 4 EnsWodGb12
   tun%(4) = -4853
WHEN "Glock2Ab5" : *CHANNELVOICE 4 Glock2Ab5
   tun%(4) = -9632
WHEN "GtMelobarC" : *CHANNELVOICE 4 GtMelobarC
   tun%(4) = -6901
WHEN "GtWashbnBb" : *CHANNELVOICE 4 GtWashbnBb
   tun%(4) = -6219
WHEN "HarmonicaE" : *CHANNELVOICE 4 HarmonicaE
   tun%(4) = -4171
WHEN "Jew'sHarpA" : *CHANNELVOICE 4 Jew'sHarpA
   tun%(4) = -6219
WHEN "MusetteB" : *CHANNELVOICE 4 MusetteB
   tun%(4) = -10656
WHEN "OboeGb" : *CHANNELVOICE 4 OboeGb
   tun%(4) = -13131
WHEN "OrchHit2B" : *CHANNELVOICE 4 OrchHit2B
   tun%(4) = -5451
WHEN "OrcSusBb23" : *CHANNELVOICE 4 OrcSusBb23
   tun%(4) = -6304
WHEN "PiccoloE" : *CHANNELVOICE 4 PiccoloE
   tun%(4) = -16544
WHEN "SaxSoprnoE" : *CHANNELVOICE 4 SaxSoprnoE
   tun%(4) = -12448
WHEN "StrngThkBb" : *CHANNELVOICE 4 StrngThkBb
   tun%(4) = -5792
WHEN "TubaGb" : *CHANNELVOICE 4 TubaGb
   tun%(4) = -929
WHEN "BassDrum" : *CHANNELVOICE 4 BassDrum
   tun%(4) = -4000
WHEN "HiHat" : *CHANNELVOICE 4 HiHat
   tun%(4) = -4000
WHEN "OrcHit" : *CHANNELVOICE 4 OrcHit
   tun%(4) = -4085
WHEN "Piano" : *CHANNELVOICE 4 Piano
   tun%(4) = -4171
WHEN "Sax" : *CHANNELVOICE 4 Sax
   tun%(4) = -4085
WHEN "Snare" : *CHANNELVOICE 4 Snare
   tun%(4) = -8096
WHEN "Choir1" : *CHANNELVOICE 4 Choir1
   tun%(4) = -6901
WHEN "ChurOrgan" : *CHANNELVOICE 4 ChurOrgan
   tun%(4) = -6901
WHEN "Opera" : *CHANNELVOICE 4 Opera
   tun%(4) = -13387
WHEN "OrchChoir" : *CHANNELVOICE 4 OrchChoir
   tun%(4) = -6133
WHEN "OrganHit" : *CHANNELVOICE 4 OrganHit
   tun%(4) = -5024
WHEN "AgogoAfric" : *CHANNELVOICE 4 AgogoAfric
   tun%(4) = -6219
WHEN "AgogoBrazi" : *CHANNELVOICE 4 AgogoBrazi
   tun%(4) = -10997
WHEN "AgogoWood" : *CHANNELVOICE 4 AgogoWood
   tun%(4) = -13728
WHEN "BDGatedRev" : *CHANNELVOICE 4 BDGatedRev
   tun%(4) = -5877
WHEN "BDMarching" : *CHANNELVOICE 4 BDMarching
   tun%(4) = -8608
WHEN "BDPiloMute" : *CHANNELVOICE 4 BDPiloMute
   tun%(4) = -7072
WHEN "Cabasa" : *CHANNELVOICE 4 Cabasa
   tun%(4) = -7072
WHEN "Cachichi1" : *CHANNELVOICE 4 Cachichi1
   tun%(4) = -4000
WHEN "CachichiTr" : *CHANNELVOICE 4 CachichiTr
   tun%(4) = -8096
WHEN "Castanets" : *CHANNELVOICE 4 Castanets
   tun%(4) = -4000
WHEN "CongaMid" : *CHANNELVOICE 4 CongaMid
   tun%(4) = -4171
WHEN "CongaSmCl" : *CHANNELVOICE 4 CongaSmCl
   tun%(4) = -4683
WHEN "CymbalCrsh" : *CHANNELVOICE 4 CymbalCrsh
   tun%(4) = -4000
WHEN "CymRideBel" : *CHANNELVOICE 4 CymRideBel
   tun%(4) = -16288
WHEN "CymRStRoll" : *CHANNELVOICE 4 CymRStRoll
   tun%(4) = -6389
WHEN "CymSplshCa" : *CHANNELVOICE 4 CymSplshCa
   tun%(4) = -9120
WHEN "Flexitone" : *CHANNELVOICE 4 Flexitone
   tun%(4) = -8096
WHEN "GongSoft" : *CHANNELVOICE 4 GongSoft
   tun%(4) = -5365
WHEN "Gonza1" : *CHANNELVOICE 4 Gonza1
   tun%(4) = -12192
WHEN "GuiroSlow" : *CHANNELVOICE 4 GuiroSlow
   tun%(4) = -6048
WHEN "HandClaps" : *CHANNELVOICE 4 HandClaps
   tun%(4) = -4000
WHEN "HiHatFoot" : *CHANNELVOICE 4 HiHatFoot
   tun%(4) = -6389
WHEN "Maracas1" : *CHANNELVOICE 4 Maracas1
   tun%(4) = -8096
WHEN "MarimbaSB3" : *CHANNELVOICE 4 MarimbaSB3
   tun%(4) = -4000
WHEN "Ratchet" : *CHANNELVOICE 4 Ratchet
   tun%(4) = -6731
WHEN "RotoTomRev" : *CHANNELVOICE 4 RotoTomRev
   tun%(4) = -6133
WHEN "SimmonsBD1" : *CHANNELVOICE 4 SimmonsBD1
   tun%(4) = -8096
WHEN "SimmonsSn1" : *CHANNELVOICE 4 SimmonsSn1
   tun%(4) = -5707
WHEN "SleighBell" : *CHANNELVOICE 4 SleighBell
   tun%(4) = -4000
WHEN "SuperGong" : *CHANNELVOICE 4 SuperGong
   tun%(4) = -4341
WHEN "SynthSnare" : *CHANNELVOICE 4 SynthSnare
   tun%(4) = -4000
WHEN "SynTom" : *CHANNELVOICE 4 SynTom
   tun%(4) = -9120
WHEN "TimpCresBb" : *CHANNELVOICE 4 TimpCresBb
   tun%(4) = -5962
WHEN "TimpLowBb" : *CHANNELVOICE 4 TimpLowBb
   tun%(4) = -5707
WHEN "TimpRollEb" : *CHANNELVOICE 4 TimpRollEb
   tun%(4) = -4000
WHEN "TomRoll" : *CHANNELVOICE 4 TomRoll
   tun%(4) = -4000
WHEN "ToyHooter" : *CHANNELVOICE 4 ToyHooter
   tun%(4) = -9717
WHEN "ToyWhistle" : *CHANNELVOICE 4 ToyWhistle
   tun%(4) = -4000
 ENDCASE


   WHEN 5 :
 CASE waveforms$(vnumber%) OF
  WHEN "WaveSynth-Beep" : *CHANNELVOICE 5 WaveSynth-Beep
  WHEN "StringLib-Soft" : *CHANNELVOICE 5 StringLib-Soft
  WHEN "StringLib-Pluck" : *CHANNELVOICE 5 StringLib-Pluck
  WHEN "StringLib-Steel" : *CHANNELVOICE 5 StringLib-Steel
  WHEN "StringLib-Hard" : *CHANNELVOICE 5 StringLib-Hard
  WHEN "Percussion-Soft" : *CHANNELVOICE 5 Percussion-Soft
  WHEN "Percussion-Medium" : *CHANNELVOICE 5 Percussion-Medium
  WHEN "Percussion-Snare" : *CHANNELVOICE 5 Percussion-Snare
  WHEN "Percussion-Noise" : *CHANNELVOICE 5 Percussion-Noise
  WHEN "BassBowAb" : *CHANNELVOICE 5 BassBowAb
    tun%(5) = -1470
  WHEN "AcouBass" : *CHANNELVOICE 5 AcouBass
   tun%(5) = -2731
  WHEN "Vibe" : *CHANNELVOICE 5 Vibe
   tun%(5) = -6912
  WHEN "BugleC" : *CHANNELVOICE 5 BugleC
   tun%(5) = -11008
  WHEN "CornetEb" : *CHANNELVOICE 5 CornetEb
   tun%(5) = -12117
  WHEN "SaxEbBarC" : *CHANNELVOICE 5 SaxEbBarC
   tun%(5) = -2816
  WHEN "SaxBbTenrE" : *CHANNELVOICE 5 SaxBbTenrE
   tun%(5) = -4181
  WHEN "BassoonEb" : *CHANNELVOICE 5 BassoonEb
   tun%(5) = -4011
  WHEN "ClarinetBb" : *CHANNELVOICE 5 ClarinetBb
   tun%(5) = -10325
  WHEN "EngHornGb" : *CHANNELVOICE 5 EngHornGb
   tun%(5) = -8960
  WHEN "MandolinDb" : *CHANNELVOICE 5 MandolinDb
   tun%(5) = -11264
  WHEN "Piano2B" : *CHANNELVOICE 5 Piano2B
   tun%(5) = -2475
  WHEN "ClarVibEb" : *CHANNELVOICE 5 ClarVibEb
   tun%(5) = -7850
  WHEN "GtrDobroB" : *CHANNELVOICE 5 GtrDobroB
   tun%(5) = -6485
  WHEN "RecorderGb" : *CHANNELVOICE 5 RecorderGb
   tun%(5) = -13056
  WHEN "FlugelHnEb" : *CHANNELVOICE 5 FlugelHnEb
   tun%(5) = -12032
  WHEN "VceMmmGb23" : *CHANNELVOICE 5 VceMmmGb23
   tun%(5) = -853
  WHEN "VceMOooGb3" : *CHANNELVOICE 5 VceMOooGb3
   tun%(5) = -4843
  WHEN "VceFemAahC" : *CHANNELVOICE 5 VceFemAahC
   tun%(5) = -10948
  WHEN "VceFMmmGb4" : *CHANNELVOICE 5 VceFMmmGb4
   tun%(5) = -8918
  WHEN "Bass" : *CHANNELVOICE 5 Bass
   tun%(5) = 0
  WHEN "ChurchBell" : *CHANNELVOICE 5 ChurchBell
   tun%(5) = -2731
  WHEN "mysound" : *CHANNELVOICE 5 mysound
    tun%(5) = 0
  WHEN "GuiroFast" : *CHANNELVOICE 5 GuiroFast
   tun%(5) = -4000
  WHEN "Clave" : *CHANNELVOICE 5 Clave
   tun%(5) = -8096
  WHEN "CowBell" : *CHANNELVOICE 5 CowBell
   tun%(5) = -5707
  WHEN "CymbRideHd" : *CHANNELVOICE 5 CymbRideHd
   tun%(5) = -8096
WHEN "AcGuitar1" : *CHANNELVOICE 5 AcGuitar1
   tun%(5) = -7072
WHEN "CongaHi" : *CHANNELVOICE 5 CongaHi
   tun%(5) = -4000
WHEN "DrumExplo" : *CHANNELVOICE 5 DrumExplo
   tun%(5) = -4000
WHEN "ElecTom1" : *CHANNELVOICE 5 ElecTom1
   tun%(5) = -8096
WHEN "Harp1" : *CHANNELVOICE 5 Harp1
   tun%(5) = -10997
WHEN "Harpsi" : *CHANNELVOICE 5 Harpsi
   tun%(5) = -6901
WHEN "HiString" : *CHANNELVOICE 5 HiString
   tun%(5) = -10997
WHEN "HonkyPiano" : *CHANNELVOICE 5 HonkyPiano
   tun%(5) = -6901
WHEN "JapFlute" : *CHANNELVOICE 5 JapFlute
   tun%(5) = -10997
WHEN "JazzOrgan" : *CHANNELVOICE 5 JazzOrgan
   tun%(5) = -10997
WHEN "MidStrings" : *CHANNELVOICE 5 MidStrings
   tun%(5) = -6901
WHEN "NoteArp1" : *CHANNELVOICE 5 NoteArp1
   tun%(5) = -4000
WHEN "SnareEcho" : *CHANNELVOICE 5 SnareEcho
   tun%(5) = -4341
WHEN "TablaHi" : *CHANNELVOICE 5 TablaHi
   tun%(5) = -7669
WHEN "Timpani" : *CHANNELVOICE 5 Timpani
   tun%(5) = -928
WHEN "Tomtom1" : *CHANNELVOICE 5 Tomtom1
   tun%(5) = -5365
WHEN "Trombone1" : *CHANNELVOICE 5 Trombone1
   tun%(5) = -6901
WHEN "Trumpet" : *CHANNELVOICE 5 Trumpet
   tun%(5) = -10997
WHEN "Xylophone" : *CHANNELVOICE 5 Xylophone
   tun%(5) = -6901
WHEN "AcouGtr2B" : *CHANNELVOICE 5 AcouGtr2B
   tun%(5) = -6560
WHEN "AcuBassAb1" : *CHANNELVOICE 5 AcuBassAb1
   tun%(5) = -1610
WHEN "BagPipeG" : *CHANNELVOICE 5 BagPipeG
   tun%(5) = -9291
WHEN "BanjoChdBb" : *CHANNELVOICE 5 BanjoChdBb
   tun%(5) = -4000
WHEN "BazookiE" : *CHANNELVOICE 5 BazookiE
   tun%(5) = -8267
WHEN "BellC" : *CHANNELVOICE 5 BellC
   tun%(5) = -10997
WHEN "BrassEns1B" : *CHANNELVOICE 5 BrassEns1B
   tun%(5) = -6560
WHEN "ClavichdBb" : *CHANNELVOICE 5 ClavichdBb
   tun%(5) = -10315
WHEN "ClavinetBb" : *CHANNELVOICE 5 ClavinetBb
   tun%(5) = -6219
WHEN "CornetEb" : *CHANNELVOICE 5 CornetEb
   tun%(5) = -4000
WHEN "EnsWodAb45" : *CHANNELVOICE 5 EnsWodAb45
   tun%(5) = -9632
WHEN "EnsWodGb12" : *CHANNELVOICE 5 EnsWodGb12
   tun%(5) = -4853
WHEN "Glock2Ab5" : *CHANNELVOICE 5 Glock2Ab5
   tun%(5) = -9632
WHEN "GtMelobarC" : *CHANNELVOICE 5 GtMelobarC
   tun%(5) = -6901
WHEN "GtWashbnBb" : *CHANNELVOICE 5 GtWashbnBb
   tun%(5) = -6219
WHEN "HarmonicaE" : *CHANNELVOICE 5 HarmonicaE
   tun%(5) = -4171
WHEN "Jew'sHarpA" : *CHANNELVOICE 5 Jew'sHarpA
   tun%(5) = -6219
WHEN "MusetteB" : *CHANNELVOICE 5 MusetteB
   tun%(5) = -10656
WHEN "OboeGb" : *CHANNELVOICE 5 OboeGb
   tun%(5) = -13131
WHEN "OrchHit2B" : *CHANNELVOICE 5 OrchHit2B
   tun%(5) = -5451
WHEN "OrcSusBb23" : *CHANNELVOICE 5 OrcSusBb23
   tun%(5) = -6304
WHEN "PiccoloE" : *CHANNELVOICE 5 PiccoloE
   tun%(5) = -16544
WHEN "SaxSoprnoE" : *CHANNELVOICE 5 SaxSoprnoE
   tun%(5) = -12448
WHEN "StrngThkBb" : *CHANNELVOICE 5 StrngThkBb
   tun%(5) = -5792
WHEN "TubaGb" : *CHANNELVOICE 5 TubaGb
   tun%(5) = -929
WHEN "BassDrum" : *CHANNELVOICE 5 BassDrum
   tun%(5) = -4000
WHEN "HiHat" : *CHANNELVOICE 5 HiHat
   tun%(5) = -4000
WHEN "OrcHit" : *CHANNELVOICE 5 OrcHit
   tun%(5) = -4085
WHEN "Piano" : *CHANNELVOICE 5 Piano
   tun%(5) = -4171
WHEN "Sax" : *CHANNELVOICE 5 Sax
   tun%(5) = -4085
WHEN "Snare" : *CHANNELVOICE 5 Snare
   tun%(5) = -8096
WHEN "Choir1" : *CHANNELVOICE 5 Choir1
   tun%(5) = -6901
WHEN "ChurOrgan" : *CHANNELVOICE 5 ChurOrgan
   tun%(5) = -6901
WHEN "Opera" : *CHANNELVOICE 5 Opera
   tun%(5) = -13387
WHEN "OrchChoir" : *CHANNELVOICE 5 OrchChoir
   tun%(5) = -6133
WHEN "OrganHit" : *CHANNELVOICE 5 OrganHit
   tun%(5) = -5024
WHEN "AgogoAfric" : *CHANNELVOICE 5 AgogoAfric
   tun%(5) = -6219
WHEN "AgogoBrazi" : *CHANNELVOICE 5 AgogoBrazi
   tun%(5) = -10997
WHEN "AgogoWood" : *CHANNELVOICE 5 AgogoWood
   tun%(5) = -13728
WHEN "BDGatedRev" : *CHANNELVOICE 5 BDGatedRev
   tun%(5) = -5877
WHEN "BDMarching" : *CHANNELVOICE 5 BDMarching
   tun%(5) = -8608
WHEN "BDPiloMute" : *CHANNELVOICE 5 BDPiloMute
   tun%(5) = -7072
WHEN "Cabasa" : *CHANNELVOICE 5 Cabasa
   tun%(5) = -7072
WHEN "Cachichi1" : *CHANNELVOICE 5 Cachichi1
   tun%(5) = -4000
WHEN "CachichiTr" : *CHANNELVOICE 5 CachichiTr
   tun%(5) = -8096
WHEN "Castanets" : *CHANNELVOICE 5 Castanets
   tun%(5) = -4000
WHEN "CongaMid" : *CHANNELVOICE 5 CongaMid
   tun%(5) = -4171
WHEN "CongaSmCl" : *CHANNELVOICE 5 CongaSmCl
   tun%(5) = -4683
WHEN "CymbalCrsh" : *CHANNELVOICE 5 CymbalCrsh
   tun%(5) = -4000
WHEN "CymRideBel" : *CHANNELVOICE 5 CymRideBel
   tun%(5) = -16288
WHEN "CymRStRoll" : *CHANNELVOICE 5 CymRStRoll
   tun%(5) = -6389
WHEN "CymSplshCa" : *CHANNELVOICE 5 CymSplshCa
   tun%(5) = -9120
WHEN "Flexitone" : *CHANNELVOICE 5 Flexitone
   tun%(5) = -8096
WHEN "GongSoft" : *CHANNELVOICE 5 GongSoft
   tun%(5) = -5365
WHEN "Gonza1" : *CHANNELVOICE 5 Gonza1
   tun%(5) = -12192
WHEN "GuiroSlow" : *CHANNELVOICE 5 GuiroSlow
   tun%(5) = -6048
WHEN "HandClaps" : *CHANNELVOICE 5 HandClaps
   tun%(5) = -4000
WHEN "HiHatFoot" : *CHANNELVOICE 5 HiHatFoot
   tun%(5) = -6389
WHEN "Maracas1" : *CHANNELVOICE 5 Maracas1
   tun%(5) = -8096
WHEN "MarimbaSB3" : *CHANNELVOICE 5 MarimbaSB3
   tun%(5) = -4000
WHEN "Ratchet" : *CHANNELVOICE 5 Ratchet
   tun%(5) = -6731
WHEN "RotoTomRev" : *CHANNELVOICE 5 RotoTomRev
   tun%(5) = -6133
WHEN "SimmonsBD1" : *CHANNELVOICE 5 SimmonsBD1
   tun%(5) = -8096
WHEN "SimmonsSn1" : *CHANNELVOICE 5 SimmonsSn1
   tun%(5) = -5707
WHEN "SleighBell" : *CHANNELVOICE 5 SleighBell
   tun%(5) = -4000
WHEN "SuperGong" : *CHANNELVOICE 5 SuperGong
   tun%(5) = -4341
WHEN "SynthSnare" : *CHANNELVOICE 5 SynthSnare
   tun%(5) = -4000
WHEN "SynTom" : *CHANNELVOICE 5 SynTom
   tun%(5) = -9120
WHEN "TimpCresBb" : *CHANNELVOICE 5 TimpCresBb
   tun%(5) = -5962
WHEN "TimpLowBb" : *CHANNELVOICE 5 TimpLowBb
   tun%(5) = -5707
WHEN "TimpRollEb" : *CHANNELVOICE 5 TimpRollEb
   tun%(5) = -4000
WHEN "TomRoll" : *CHANNELVOICE 5 TomRoll
   tun%(5) = -4000
WHEN "ToyHooter" : *CHANNELVOICE 5 ToyHooter
   tun%(5) = -9717
WHEN "ToyWhistle" : *CHANNELVOICE 5 ToyWhistle
   tun%(5) = -4000
 ENDCASE


   WHEN 6 :
 CASE waveforms$(vnumber%) OF
  WHEN "WaveSynth-Beep" : *CHANNELVOICE 6 WaveSynth-Beep
  WHEN "StringLib-Soft" : *CHANNELVOICE 6 StringLib-Soft
  WHEN "StringLib-Pluck" : *CHANNELVOICE 6 StringLib-Pluck
  WHEN "StringLib-Steel" : *CHANNELVOICE 6 StringLib-Steel
  WHEN "StringLib-Hard" : *CHANNELVOICE 6 StringLib-Hard
  WHEN "Percussion-Soft" : *CHANNELVOICE 6 Percussion-Soft
  WHEN "Percussion-Medium" : *CHANNELVOICE 6 Percussion-Medium
  WHEN "Percussion-Snare" : *CHANNELVOICE 6 Percussion-Snare
  WHEN "Percussion-Noise" : *CHANNELVOICE 6 Percussion-Noise
  WHEN "BassBowAb" : *CHANNELVOICE 6 BassBowAb
    tun%(6) = -1470
  WHEN "AcouBass" : *CHANNELVOICE 6 AcouBass
   tun%(6) = -2731
  WHEN "Vibe" : *CHANNELVOICE 6 Vibe
   tun%(6) = -6912
  WHEN "BugleC" : *CHANNELVOICE 6 BugleC
   tun%(6) = -11008
  WHEN "CornetEb" : *CHANNELVOICE 6 CornetEb
   tun%(6) = -12117
  WHEN "SaxEbBarC" : *CHANNELVOICE 6 SaxEbBarC
   tun%(6) = -2816
  WHEN "SaxBbTenrE" : *CHANNELVOICE 6 SaxBbTenrE
   tun%(6) = -4181
  WHEN "BassoonEb" : *CHANNELVOICE 6 BassoonEb
   tun%(6) = -4011
  WHEN "ClarinetBb" : *CHANNELVOICE 6 ClarinetBb
   tun%(6) = -10325
  WHEN "EngHornGb" : *CHANNELVOICE 6 EngHornGb
   tun%(6) = -8960
  WHEN "MandolinDb" : *CHANNELVOICE 6 MandolinDb
   tun%(6) = -11264
  WHEN "Piano2B" : *CHANNELVOICE 6 Piano2B
   tun%(6) = -2475
  WHEN "ClarVibEb" : *CHANNELVOICE 6 ClarVibEb
   tun%(6) = -7850
  WHEN "GtrDobroB" : *CHANNELVOICE 6 GtrDobroB
   tun%(6) = -6485
  WHEN "RecorderGb" : *CHANNELVOICE 6 RecorderGb
   tun%(6) = -13056
  WHEN "FlugelHnEb" : *CHANNELVOICE 6 FlugelHnEb
   tun%(6) = -12032
  WHEN "VceMmmGb23" : *CHANNELVOICE 6 VceMmmGb23
   tun%(6) = -853
  WHEN "VceMOooGb3" : *CHANNELVOICE 6 VceMOooGb3
   tun%(6) = -4843
  WHEN "VceFemAahC" : *CHANNELVOICE 6 VceFemAahC
   tun%(6) = -10948
  WHEN "VceFMmmGb4" : *CHANNELVOICE 6 VceFMmmGb4
   tun%(6) = -8918
  WHEN "Bass" : *CHANNELVOICE 6 Bass
   tun%(6) = 0
  WHEN "ChurchBell" : *CHANNELVOICE 6 ChurchBell
   tun%(6) = -2731
  WHEN "mysound" : *CHANNELVOICE 6 mysound
    tun%(6) = 0
  WHEN "GuiroFast" : *CHANNELVOICE 6 GuiroFast
   tun%(6) = -4000
  WHEN "Clave" : *CHANNELVOICE 6 Clave
   tun%(6) = -8096
  WHEN "CowBell" : *CHANNELVOICE 6 CowBell
   tun%(6) = -5707
  WHEN "CymbRideHd" : *CHANNELVOICE 6 CymbRideHd
   tun%(6) = -8096
WHEN "AcGuitar1" : *CHANNELVOICE 6 AcGuitar1
   tun%(6) = -7072
WHEN "CongaHi" : *CHANNELVOICE 6 CongaHi
   tun%(6) = -4000
WHEN "DrumExplo" : *CHANNELVOICE 6 DrumExplo
   tun%(6) = -4000
WHEN "ElecTom1" : *CHANNELVOICE 6 ElecTom1
   tun%(6) = -8096
WHEN "Harp1" : *CHANNELVOICE 6 Harp1
   tun%(6) = -10997
WHEN "Harpsi" : *CHANNELVOICE 6 Harpsi
   tun%(6) = -6901
WHEN "HiString" : *CHANNELVOICE 6 HiString
   tun%(6) = -10997
WHEN "HonkyPiano" : *CHANNELVOICE 6 HonkyPiano
   tun%(6) = -6901
WHEN "JapFlute" : *CHANNELVOICE 6 JapFlute
   tun%(6) = -10997
WHEN "JazzOrgan" : *CHANNELVOICE 6 JazzOrgan
   tun%(6) = -10997
WHEN "MidStrings" : *CHANNELVOICE 6 MidStrings
   tun%(6) = -6901
WHEN "NoteArp1" : *CHANNELVOICE 6 NoteArp1
   tun%(6) = -4000
WHEN "SnareEcho" : *CHANNELVOICE 6 SnareEcho
   tun%(6) = -4341
WHEN "TablaHi" : *CHANNELVOICE 6 TablaHi
   tun%(6) = -7669
WHEN "Timpani" : *CHANNELVOICE 6 Timpani
   tun%(6) = -928
WHEN "Tomtom1" : *CHANNELVOICE 6 Tomtom1
   tun%(6) = -5365
WHEN "Trombone1" : *CHANNELVOICE 6 Trombone1
   tun%(6) = -6901
WHEN "Trumpet" : *CHANNELVOICE 6 Trumpet
   tun%(6) = -10997
WHEN "Xylophone" : *CHANNELVOICE 6 Xylophone
   tun%(6) = -6901
WHEN "AcouGtr2B" : *CHANNELVOICE 6 AcouGtr2B
   tun%(6) = -6560
WHEN "AcuBassAb1" : *CHANNELVOICE 6 AcuBassAb1
   tun%(6) = -1610
WHEN "BagPipeG" : *CHANNELVOICE 6 BagPipeG
   tun%(6) = -9291
WHEN "BanjoChdBb" : *CHANNELVOICE 6 BanjoChdBb
   tun%(6) = -4000
WHEN "BazookiE" : *CHANNELVOICE 6 BazookiE
   tun%(6) = -8267
WHEN "BellC" : *CHANNELVOICE 6 BellC
   tun%(6) = -10997
WHEN "BrassEns1B" : *CHANNELVOICE 6 BrassEns1B
   tun%(6) = -6560
WHEN "ClavichdBb" : *CHANNELVOICE 6 ClavichdBb
   tun%(6) = -10315
WHEN "ClavinetBb" : *CHANNELVOICE 6 ClavinetBb
   tun%(6) = -6219
WHEN "CornetEb" : *CHANNELVOICE 6 CornetEb
   tun%(6) = -4000
WHEN "EnsWodAb45" : *CHANNELVOICE 6 EnsWodAb45
   tun%(6) = -9632
WHEN "EnsWodGb12" : *CHANNELVOICE 6 EnsWodGb12
   tun%(6) = -4853
WHEN "Glock2Ab5" : *CHANNELVOICE 6 Glock2Ab5
   tun%(6) = -9632
WHEN "GtMelobarC" : *CHANNELVOICE 6 GtMelobarC
   tun%(6) = -6901
WHEN "GtWashbnBb" : *CHANNELVOICE 6 GtWashbnBb
   tun%(6) = -6219
WHEN "HarmonicaE" : *CHANNELVOICE 6 HarmonicaE
   tun%(6) = -4171
WHEN "Jew'sHarpA" : *CHANNELVOICE 6 Jew'sHarpA
   tun%(6) = -6219
WHEN "MusetteB" : *CHANNELVOICE 6 MusetteB
   tun%(6) = -10656
WHEN "OboeGb" : *CHANNELVOICE 6 OboeGb
   tun%(6) = -13131
WHEN "OrchHit2B" : *CHANNELVOICE 6 OrchHit2B
   tun%(6) = -5451
WHEN "OrcSusBb23" : *CHANNELVOICE 6 OrcSusBb23
   tun%(6) = -6304
WHEN "PiccoloE" : *CHANNELVOICE 6 PiccoloE
   tun%(6) = -16544
WHEN "SaxSoprnoE" : *CHANNELVOICE 6 SaxSoprnoE
   tun%(6) = -12448
WHEN "StrngThkBb" : *CHANNELVOICE 6 StrngThkBb
   tun%(6) = -5792
WHEN "TubaGb" : *CHANNELVOICE 6 TubaGb
   tun%(6) = -929
WHEN "BassDrum" : *CHANNELVOICE 6 BassDrum
   tun%(6) = -4000
WHEN "HiHat" : *CHANNELVOICE 6 HiHat
   tun%(6) = -4000
WHEN "OrcHit" : *CHANNELVOICE 6 OrcHit
   tun%(6) = -4085
WHEN "Piano" : *CHANNELVOICE 6 Piano
   tun%(6) = -4171
WHEN "Sax" : *CHANNELVOICE 6 Sax
   tun%(6) = -4085
WHEN "Snare" : *CHANNELVOICE 6 Snare
   tun%(6) = -8096
WHEN "Choir1" : *CHANNELVOICE 6 Choir1
   tun%(6) = -6901
WHEN "ChurOrgan" : *CHANNELVOICE 6 ChurOrgan
   tun%(6) = -6901
WHEN "Opera" : *CHANNELVOICE 6 Opera
   tun%(6) = -13387
WHEN "OrchChoir" : *CHANNELVOICE 6 OrchChoir
   tun%(6) = -6133
WHEN "OrganHit" : *CHANNELVOICE 6 OrganHit
   tun%(6) = -5024
WHEN "AgogoAfric" : *CHANNELVOICE 6 AgogoAfric
   tun%(6) = -6219
WHEN "AgogoBrazi" : *CHANNELVOICE 6 AgogoBrazi
   tun%(6) = -10997
WHEN "AgogoWood" : *CHANNELVOICE 6 AgogoWood
   tun%(6) = -13728
WHEN "BDGatedRev" : *CHANNELVOICE 6 BDGatedRev
   tun%(6) = -5877
WHEN "BDMarching" : *CHANNELVOICE 6 BDMarching
   tun%(6) = -8608
WHEN "BDPiloMute" : *CHANNELVOICE 6 BDPiloMute
   tun%(6) = -7072
WHEN "Cabasa" : *CHANNELVOICE 6 Cabasa
   tun%(6) = -7072
WHEN "Cachichi1" : *CHANNELVOICE 6 Cachichi1
   tun%(6) = -4000
WHEN "CachichiTr" : *CHANNELVOICE 6 CachichiTr
   tun%(6) = -8096
WHEN "Castanets" : *CHANNELVOICE 6 Castanets
   tun%(6) = -4000
WHEN "CongaMid" : *CHANNELVOICE 6 CongaMid
   tun%(6) = -4171
WHEN "CongaSmCl" : *CHANNELVOICE 6 CongaSmCl
   tun%(6) = -4683
WHEN "CymbalCrsh" : *CHANNELVOICE 6 CymbalCrsh
   tun%(6) = -4000
WHEN "CymRideBel" : *CHANNELVOICE 6 CymRideBel
   tun%(6) = -16288
WHEN "CymRStRoll" : *CHANNELVOICE 6 CymRStRoll
   tun%(6) = -6389
WHEN "CymSplshCa" : *CHANNELVOICE 6 CymSplshCa
   tun%(6) = -9120
WHEN "Flexitone" : *CHANNELVOICE 6 Flexitone
   tun%(6) = -8096
WHEN "GongSoft" : *CHANNELVOICE 6 GongSoft
   tun%(6) = -5365
WHEN "Gonza1" : *CHANNELVOICE 6 Gonza1
   tun%(6) = -12192
WHEN "GuiroSlow" : *CHANNELVOICE 6 GuiroSlow
   tun%(6) = -6048
WHEN "HandClaps" : *CHANNELVOICE 6 HandClaps
   tun%(6) = -4000
WHEN "HiHatFoot" : *CHANNELVOICE 6 HiHatFoot
   tun%(6) = -6389
WHEN "Maracas1" : *CHANNELVOICE 6 Maracas1
   tun%(6) = -8096
WHEN "MarimbaSB3" : *CHANNELVOICE 6 MarimbaSB3
   tun%(6) = -4000
WHEN "Ratchet" : *CHANNELVOICE 6 Ratchet
   tun%(6) = -6731
WHEN "RotoTomRev" : *CHANNELVOICE 6 RotoTomRev
   tun%(6) = -6133
WHEN "SimmonsBD1" : *CHANNELVOICE 6 SimmonsBD1
   tun%(6) = -8096
WHEN "SimmonsSn1" : *CHANNELVOICE 6 SimmonsSn1
   tun%(6) = -5707
WHEN "SleighBell" : *CHANNELVOICE 6 SleighBell
   tun%(6) = -4000
WHEN "SuperGong" : *CHANNELVOICE 6 SuperGong
   tun%(6) = -4341
WHEN "SynthSnare" : *CHANNELVOICE 6 SynthSnare
   tun%(6) = -4000
WHEN "SynTom" : *CHANNELVOICE 6 SynTom
   tun%(6) = -9120
WHEN "TimpCresBb" : *CHANNELVOICE 6 TimpCresBb
   tun%(6) = -5962
WHEN "TimpLowBb" : *CHANNELVOICE 6 TimpLowBb
   tun%(6) = -5707
WHEN "TimpRollEb" : *CHANNELVOICE 6 TimpRollEb
   tun%(6) = -4000
WHEN "TomRoll" : *CHANNELVOICE 6 TomRoll
   tun%(6) = -4000
WHEN "ToyHooter" : *CHANNELVOICE 6 ToyHooter
   tun%(6) = -9717
WHEN "ToyWhistle" : *CHANNELVOICE 6 ToyWhistle
   tun%(6) = -4000
 ENDCASE


   WHEN 7 :
 CASE waveforms$(vnumber%) OF
  WHEN "WaveSynth-Beep" : *CHANNELVOICE 7 WaveSynth-Beep
  WHEN "StringLib-Soft" : *CHANNELVOICE 7 StringLib-Soft
  WHEN "StringLib-Pluck" : *CHANNELVOICE 7 StringLib-Pluck
  WHEN "StringLib-Steel" : *CHANNELVOICE 7 StringLib-Steel
  WHEN "StringLib-Hard" : *CHANNELVOICE 7 StringLib-Hard
  WHEN "Percussion-Soft" : *CHANNELVOICE 7 Percussion-Soft
  WHEN "Percussion-Medium" : *CHANNELVOICE 7 Percussion-Medium
  WHEN "Percussion-Snare" : *CHANNELVOICE 7 Percussion-Snare
  WHEN "Percussion-Noise" : *CHANNELVOICE 7 Percussion-Noise
  WHEN "BassBowAb" : *CHANNELVOICE 7 BassBowAb
    tun%(7) = -1470
  WHEN "AcouBass" : *CHANNELVOICE 7 AcouBass
   tun%(7) = -2731
  WHEN "Vibe" : *CHANNELVOICE 7 Vibe
   tun%(7) = -6912
  WHEN "BugleC" : *CHANNELVOICE 7 BugleC
   tun%(7) = -11008
  WHEN "CornetEb" : *CHANNELVOICE 7 CornetEb
   tun%(7) = -12117
  WHEN "SaxEbBarC" : *CHANNELVOICE 7 SaxEbBarC
   tun%(7) = -2816
  WHEN "SaxBbTenrE" : *CHANNELVOICE 7 SaxBbTenrE
   tun%(7) = -4181
  WHEN "BassoonEb" : *CHANNELVOICE 7 BassoonEb
   tun%(7) = -4011
  WHEN "ClarinetBb" : *CHANNELVOICE 7 ClarinetBb
   tun%(7) = -10325
  WHEN "EngHornGb" : *CHANNELVOICE 7 EngHornGb
   tun%(7) = -8960
  WHEN "MandolinDb" : *CHANNELVOICE 7 MandolinDb
   tun%(7) = -11264
  WHEN "Piano2B" : *CHANNELVOICE 7 Piano2B
   tun%(7) = -2475
  WHEN "ClarVibEb" : *CHANNELVOICE 7 ClarVibEb
   tun%(7) = -7850
  WHEN "GtrDobroB" : *CHANNELVOICE 7 GtrDobroB
   tun%(7) = -6485
  WHEN "RecorderGb" : *CHANNELVOICE 7 RecorderGb
   tun%(7) = -13056
  WHEN "FlugelHnEb" : *CHANNELVOICE 7 FlugelHnEb
   tun%(7) = -12032
  WHEN "VceMmmGb23" : *CHANNELVOICE 7 VceMmmGb23
   tun%(7) = -853
  WHEN "VceMOooGb3" : *CHANNELVOICE 7 VceMOooGb3
   tun%(7) = -4843
  WHEN "VceFemAahC" : *CHANNELVOICE 7 VceFemAahC
   tun%(7) = -10948
  WHEN "VceFMmmGb4" : *CHANNELVOICE 7 VceFMmmGb4
   tun%(7) = -8918
  WHEN "Bass" : *CHANNELVOICE 7 Bass
   tun%(7) = 0
  WHEN "ChurchBell" : *CHANNELVOICE 7 ChurchBell
   tun%(7) = -2731
  WHEN "mysound" : *CHANNELVOICE 7 mysound
    tun%(7) = 0
  WHEN "GuiroFast" : *CHANNELVOICE 7 GuiroFast
   tun%(7) = -4000
  WHEN "Clave" : *CHANNELVOICE 7 Clave
   tun%(7) = -8096
  WHEN "CowBell" : *CHANNELVOICE 7 CowBell
   tun%(7) = -5707
  WHEN "CymbRideHd" : *CHANNELVOICE 7 CymbRideHd
   tun%(7) = -8096
WHEN "AcGuitar1" : *CHANNELVOICE 7 AcGuitar1
   tun%(7) = -7072
WHEN "CongaHi" : *CHANNELVOICE 7 CongaHi
   tun%(7) = -4000
WHEN "DrumExplo" : *CHANNELVOICE 7 DrumExplo
   tun%(7) = -4000
WHEN "ElecTom1" : *CHANNELVOICE 7 ElecTom1
   tun%(7) = -8096
WHEN "Harp1" : *CHANNELVOICE 7 Harp1
   tun%(7) = -10997
WHEN "Harpsi" : *CHANNELVOICE 7 Harpsi
   tun%(7) = -6901
WHEN "HiString" : *CHANNELVOICE 7 HiString
   tun%(7) = -10997
WHEN "HonkyPiano" : *CHANNELVOICE 7 HonkyPiano
   tun%(7) = -6901
WHEN "JapFlute" : *CHANNELVOICE 7 JapFlute
   tun%(7) = -10997
WHEN "JazzOrgan" : *CHANNELVOICE 7 JazzOrgan
   tun%(7) = -10997
WHEN "MidStrings" : *CHANNELVOICE 7 MidStrings
   tun%(7) = -6901
WHEN "NoteArp1" : *CHANNELVOICE 7 NoteArp1
   tun%(7) = -4000
WHEN "SnareEcho" : *CHANNELVOICE 7 SnareEcho
   tun%(7) = -4341
WHEN "TablaHi" : *CHANNELVOICE 7 TablaHi
   tun%(7) = -7669
WHEN "Timpani" : *CHANNELVOICE 7 Timpani
   tun%(7) = -928
WHEN "Tomtom1" : *CHANNELVOICE 7 Tomtom1
   tun%(7) = -5365
WHEN "Trombone1" : *CHANNELVOICE 7 Trombone1
   tun%(7) = -6901
WHEN "Trumpet" : *CHANNELVOICE 7 Trumpet
   tun%(7) = -10997
WHEN "Xylophone" : *CHANNELVOICE 7 Xylophone
   tun%(7) = -6901
WHEN "AcouGtr2B" : *CHANNELVOICE 7 AcouGtr2B
   tun%(7) = -6560
WHEN "AcuBassAb1" : *CHANNELVOICE 7 AcuBassAb1
   tun%(7) = -1610
WHEN "BagPipeG" : *CHANNELVOICE 7 BagPipeG
   tun%(7) = -9291
WHEN "BanjoChdBb" : *CHANNELVOICE 7 BanjoChdBb
   tun%(7) = -4000
WHEN "BazookiE" : *CHANNELVOICE 7 BazookiE
   tun%(7) = -8267
WHEN "BellC" : *CHANNELVOICE 7 BellC
   tun%(7) = -10997
WHEN "BrassEns1B" : *CHANNELVOICE 7 BrassEns1B
   tun%(7) = -6560
WHEN "ClavichdBb" : *CHANNELVOICE 7 ClavichdBb
   tun%(7) = -10315
WHEN "ClavinetBb" : *CHANNELVOICE 7 ClavinetBb
   tun%(7) = -6219
WHEN "CornetEb" : *CHANNELVOICE 7 CornetEb
   tun%(7) = -4000
WHEN "EnsWodAb45" : *CHANNELVOICE 7 EnsWodAb45
   tun%(7) = -9632
WHEN "EnsWodGb12" : *CHANNELVOICE 7 EnsWodGb12
   tun%(7) = -4853
WHEN "Glock2Ab5" : *CHANNELVOICE 7 Glock2Ab5
   tun%(7) = -9632
WHEN "GtMelobarC" : *CHANNELVOICE 7 GtMelobarC
   tun%(7) = -6901
WHEN "GtWashbnBb" : *CHANNELVOICE 7 GtWashbnBb
   tun%(7) = -6219
WHEN "HarmonicaE" : *CHANNELVOICE 7 HarmonicaE
   tun%(7) = -4171
WHEN "Jew'sHarpA" : *CHANNELVOICE 7 Jew'sHarpA
   tun%(7) = -6219
WHEN "MusetteB" : *CHANNELVOICE 7 MusetteB
   tun%(7) = -10656
WHEN "OboeGb" : *CHANNELVOICE 7 OboeGb
   tun%(7) = -13131
WHEN "OrchHit2B" : *CHANNELVOICE 7 OrchHit2B
   tun%(7) = -5451
WHEN "OrcSusBb23" : *CHANNELVOICE 7 OrcSusBb23
   tun%(7) = -6304
WHEN "PiccoloE" : *CHANNELVOICE 7 PiccoloE
   tun%(7) = -16544
WHEN "SaxSoprnoE" : *CHANNELVOICE 7 SaxSoprnoE
   tun%(7) = -12448
WHEN "StrngThkBb" : *CHANNELVOICE 7 StrngThkBb
   tun%(7) = -5792
WHEN "TubaGb" : *CHANNELVOICE 7 TubaGb
   tun%(7) = -929
WHEN "BassDrum" : *CHANNELVOICE 7 BassDrum
   tun%(7) = -4000
WHEN "HiHat" : *CHANNELVOICE 7 HiHat
   tun%(7) = -4000
WHEN "OrcHit" : *CHANNELVOICE 7 OrcHit
   tun%(7) = -4085
WHEN "Piano" : *CHANNELVOICE 7 Piano
   tun%(7) = -4171
WHEN "Sax" : *CHANNELVOICE 7 Sax
   tun%(7) = -4085
WHEN "Snare" : *CHANNELVOICE 7 Snare
   tun%(7) = -8096
WHEN "Choir1" : *CHANNELVOICE 7 Choir1
   tun%(7) = -6901
WHEN "ChurOrgan" : *CHANNELVOICE 7 ChurOrgan
   tun%(7) = -6901
WHEN "Opera" : *CHANNELVOICE 7 Opera
   tun%(7) = -13387
WHEN "OrchChoir" : *CHANNELVOICE 7 OrchChoir
   tun%(7) = -6133
WHEN "OrganHit" : *CHANNELVOICE 7 OrganHit
   tun%(7) = -5024
WHEN "AgogoAfric" : *CHANNELVOICE 7 AgogoAfric
   tun%(7) = -6219
WHEN "AgogoBrazi" : *CHANNELVOICE 7 AgogoBrazi
   tun%(7) = -10997
WHEN "AgogoWood" : *CHANNELVOICE 7 AgogoWood
   tun%(7) = -13728
WHEN "BDGatedRev" : *CHANNELVOICE 7 BDGatedRev
   tun%(7) = -5877
WHEN "BDMarching" : *CHANNELVOICE 7 BDMarching
   tun%(7) = -8608
WHEN "BDPiloMute" : *CHANNELVOICE 7 BDPiloMute
   tun%(7) = -7072
WHEN "Cabasa" : *CHANNELVOICE 7 Cabasa
   tun%(7) = -7072
WHEN "Cachichi1" : *CHANNELVOICE 7 Cachichi1
   tun%(7) = -4000
WHEN "CachichiTr" : *CHANNELVOICE 7 CachichiTr
   tun%(7) = -8096
WHEN "Castanets" : *CHANNELVOICE 7 Castanets
   tun%(7) = -4000
WHEN "CongaMid" : *CHANNELVOICE 7 CongaMid
   tun%(7) = -4171
WHEN "CongaSmCl" : *CHANNELVOICE 7 CongaSmCl
   tun%(7) = -4683
WHEN "CymbalCrsh" : *CHANNELVOICE 7 CymbalCrsh
   tun%(7) = -4000
WHEN "CymRideBel" : *CHANNELVOICE 7 CymRideBel
   tun%(7) = -16288
WHEN "CymRStRoll" : *CHANNELVOICE 7 CymRStRoll
   tun%(7) = -6389
WHEN "CymSplshCa" : *CHANNELVOICE 7 CymSplshCa
   tun%(7) = -9120
WHEN "Flexitone" : *CHANNELVOICE 7 Flexitone
   tun%(7) = -8096
WHEN "GongSoft" : *CHANNELVOICE 7 GongSoft
   tun%(7) = -5365
WHEN "Gonza1" : *CHANNELVOICE 7 Gonza1
   tun%(7) = -12192
WHEN "GuiroSlow" : *CHANNELVOICE 7 GuiroSlow
   tun%(7) = -6048
WHEN "HandClaps" : *CHANNELVOICE 7 HandClaps
   tun%(7) = -4000
WHEN "HiHatFoot" : *CHANNELVOICE 7 HiHatFoot
   tun%(7) = -6389
WHEN "Maracas1" : *CHANNELVOICE 7 Maracas1
   tun%(7) = -8096
WHEN "MarimbaSB3" : *CHANNELVOICE 7 MarimbaSB3
   tun%(7) = -4000
WHEN "Ratchet" : *CHANNELVOICE 7 Ratchet
   tun%(7) = -6731
WHEN "RotoTomRev" : *CHANNELVOICE 7 RotoTomRev
   tun%(7) = -6133
WHEN "SimmonsBD1" : *CHANNELVOICE 7 SimmonsBD1
   tun%(7) = -8096
WHEN "SimmonsSn1" : *CHANNELVOICE 7 SimmonsSn1
   tun%(7) = -5707
WHEN "SleighBell" : *CHANNELVOICE 7 SleighBell
   tun%(7) = -4000
WHEN "SuperGong" : *CHANNELVOICE 7 SuperGong
   tun%(7) = -4341
WHEN "SynthSnare" : *CHANNELVOICE 7 SynthSnare
   tun%(7) = -4000
WHEN "SynTom" : *CHANNELVOICE 7 SynTom
   tun%(7) = -9120
WHEN "TimpCresBb" : *CHANNELVOICE 7 TimpCresBb
   tun%(7) = -5962
WHEN "TimpLowBb" : *CHANNELVOICE 7 TimpLowBb
   tun%(7) = -5707
WHEN "TimpRollEb" : *CHANNELVOICE 7 TimpRollEb
   tun%(7) = -4000
WHEN "TomRoll" : *CHANNELVOICE 7 TomRoll
   tun%(7) = -4000
WHEN "ToyHooter" : *CHANNELVOICE 7 ToyHooter
   tun%(7) = -9717
WHEN "ToyWhistle" : *CHANNELVOICE 7 ToyWhistle
   tun%(7) = -4000
 ENDCASE


   WHEN 8 :
 CASE waveforms$(vnumber%) OF
  WHEN "WaveSynth-Beep" : *CHANNELVOICE 8 WaveSynth-Beep
  WHEN "StringLib-Soft" : *CHANNELVOICE 8 StringLib-Soft
  WHEN "StringLib-Pluck" : *CHANNELVOICE 8 StringLib-Pluck
  WHEN "StringLib-Steel" : *CHANNELVOICE 8 StringLib-Steel
  WHEN "StringLib-Hard" : *CHANNELVOICE 8 StringLib-Hard
  WHEN "Percussion-Soft" : *CHANNELVOICE 8 Percussion-Soft
  WHEN "Percussion-Medium" : *CHANNELVOICE 8 Percussion-Medium
  WHEN "Percussion-Snare" : *CHANNELVOICE 8 Percussion-Snare
  WHEN "Percussion-Noise" : *CHANNELVOICE 8 Percussion-Noise
  WHEN "BassBowAb" : *CHANNELVOICE 8 BassBowAb
    tun%(8) = -1470
  WHEN "AcouBass" : *CHANNELVOICE 8 AcouBass
   tun%(8) = -2731
  WHEN "Vibe" : *CHANNELVOICE 8 Vibe
   tun%(8) = -6912
  WHEN "BugleC" : *CHANNELVOICE 8 BugleC
   tun%(8) = -11008
  WHEN "CornetEb" : *CHANNELVOICE 8 CornetEb
   tun%(8) = -12117
  WHEN "SaxEbBarC" : *CHANNELVOICE 8 SaxEbBarC
   tun%(8) = -2816
  WHEN "SaxBbTenrE" : *CHANNELVOICE 8 SaxBbTenrE
   tun%(8) = -4181
  WHEN "BassoonEb" : *CHANNELVOICE 8 BassoonEb
   tun%(8) = -4011
  WHEN "ClarinetBb" : *CHANNELVOICE 8 ClarinetBb
   tun%(8) = -10325
  WHEN "EngHornGb" : *CHANNELVOICE 8 EngHornGb
   tun%(8) = -8960
  WHEN "MandolinDb" : *CHANNELVOICE 8 MandolinDb
   tun%(8) = -11264
  WHEN "Piano2B" : *CHANNELVOICE 8 Piano2B
   tun%(8) = -2475
  WHEN "ClarVibEb" : *CHANNELVOICE 8 ClarVibEb
   tun%(8) = -7850
  WHEN "GtrDobroB" : *CHANNELVOICE 8 GtrDobroB
   tun%(8) = -6485
  WHEN "RecorderGb" : *CHANNELVOICE 8 RecorderGb
   tun%(8) = -13056
  WHEN "FlugelHnEb" : *CHANNELVOICE 8 FlugelHnEb
   tun%(8) = -12032
  WHEN "VceMmmGb23" : *CHANNELVOICE 8 VceMmmGb23
   tun%(8) = -853
  WHEN "VceMOooGb3" : *CHANNELVOICE 8 VceMOooGb3
   tun%(8) = -4843
  WHEN "VceFemAahC" : *CHANNELVOICE 8 VceFemAahC
   tun%(8) = -10948
  WHEN "VceFMmmGb4" : *CHANNELVOICE 8 VceFMmmGb4
   tun%(8) = -8918
  WHEN "Bass" : *CHANNELVOICE 8 Bass
   tun%(8) = 0
  WHEN "ChurchBell" : *CHANNELVOICE 8 ChurchBell
   tun%(8) = -2731
  WHEN "mysound" : *CHANNELVOICE 8 mysound
    tun%(8) = 0
  WHEN "GuiroFast" : *CHANNELVOICE 8 GuiroFast
   tun%(8) = -4000
  WHEN "Clave" : *CHANNELVOICE 8 Clave
   tun%(8) = -8096
  WHEN "CowBell" : *CHANNELVOICE 8 CowBell
   tun%(8) = -5707
  WHEN "CymbRideHd" : *CHANNELVOICE 8 CymbRideHd
   tun%(8) = -8096
WHEN "AcGuitar1" : *CHANNELVOICE 8 AcGuitar1
   tun%(8) = -7072
WHEN "CongaHi" : *CHANNELVOICE 8 CongaHi
   tun%(8) = -4000
WHEN "DrumExplo" : *CHANNELVOICE 8 DrumExplo
   tun%(8) = -4000
WHEN "ElecTom1" : *CHANNELVOICE 8 ElecTom1
   tun%(8) = -8096
WHEN "Harp1" : *CHANNELVOICE 8 Harp1
   tun%(8) = -10997
WHEN "Harpsi" : *CHANNELVOICE 8 Harpsi
   tun%(8) = -6901
WHEN "HiString" : *CHANNELVOICE 8 HiString
   tun%(8) = -10997
WHEN "HonkyPiano" : *CHANNELVOICE 8 HonkyPiano
   tun%(8) = -6901
WHEN "JapFlute" : *CHANNELVOICE 8 JapFlute
   tun%(8) = -10997
WHEN "JazzOrgan" : *CHANNELVOICE 8 JazzOrgan
   tun%(8) = -10997
WHEN "MidStrings" : *CHANNELVOICE 8 MidStrings
   tun%(8) = -6901
WHEN "NoteArp1" : *CHANNELVOICE 8 NoteArp1
   tun%(8) = -4000
WHEN "SnareEcho" : *CHANNELVOICE 8 SnareEcho
   tun%(8) = -4341
WHEN "TablaHi" : *CHANNELVOICE 8 TablaHi
   tun%(8) = -7669
WHEN "Timpani" : *CHANNELVOICE 8 Timpani
   tun%(8) = -928
WHEN "Tomtom1" : *CHANNELVOICE 8 Tomtom1
   tun%(8) = -5365
WHEN "Trombone1" : *CHANNELVOICE 8 Trombone1
   tun%(8) = -6901
WHEN "Trumpet" : *CHANNELVOICE 8 Trumpet
   tun%(8) = -10997
WHEN "Xylophone" : *CHANNELVOICE 8 Xylophone
   tun%(8) = -6901
WHEN "AcouGtr2B" : *CHANNELVOICE 8 AcouGtr2B
   tun%(8) = -6560
WHEN "AcuBassAb1" : *CHANNELVOICE 8 AcuBassAb1
   tun%(8) = -1610
WHEN "BagPipeG" : *CHANNELVOICE 8 BagPipeG
   tun%(8) = -9291
WHEN "BanjoChdBb" : *CHANNELVOICE 8 BanjoChdBb
   tun%(8) = -4000
WHEN "BazookiE" : *CHANNELVOICE 8 BazookiE
   tun%(8) = -8267
WHEN "BellC" : *CHANNELVOICE 8 BellC
   tun%(8) = -10997
WHEN "BrassEns1B" : *CHANNELVOICE 8 BrassEns1B
   tun%(8) = -6560
WHEN "ClavichdBb" : *CHANNELVOICE 8 ClavichdBb
   tun%(8) = -10315
WHEN "ClavinetBb" : *CHANNELVOICE 8 ClavinetBb
   tun%(8) = -6219
WHEN "CornetEb" : *CHANNELVOICE 8 CornetEb
   tun%(8) = -4000
WHEN "EnsWodAb45" : *CHANNELVOICE 8 EnsWodAb45
   tun%(8) = -9632
WHEN "EnsWodGb12" : *CHANNELVOICE 8 EnsWodGb12
   tun%(8) = -4853
WHEN "Glock2Ab5" : *CHANNELVOICE 8 Glock2Ab5
   tun%(8) = -9632
WHEN "GtMelobarC" : *CHANNELVOICE 8 GtMelobarC
   tun%(8) = -6901
WHEN "GtWashbnBb" : *CHANNELVOICE 8 GtWashbnBb
   tun%(8) = -6219
WHEN "HarmonicaE" : *CHANNELVOICE 8 HarmonicaE
   tun%(8) = -4171
WHEN "Jew'sHarpA" : *CHANNELVOICE 8 Jew'sHarpA
   tun%(8) = -6219
WHEN "MusetteB" : *CHANNELVOICE 8 MusetteB
   tun%(8) = -10656
WHEN "OboeGb" : *CHANNELVOICE 8 OboeGb
   tun%(8) = -13131
WHEN "OrchHit2B" : *CHANNELVOICE 8 OrchHit2B
   tun%(8) = -5451
WHEN "OrcSusBb23" : *CHANNELVOICE 8 OrcSusBb23
   tun%(8) = -6304
WHEN "PiccoloE" : *CHANNELVOICE 8 PiccoloE
   tun%(8) = -16544
WHEN "SaxSoprnoE" : *CHANNELVOICE 8 SaxSoprnoE
   tun%(8) = -12448
WHEN "StrngThkBb" : *CHANNELVOICE 8 StrngThkBb
   tun%(8) = -5792
WHEN "TubaGb" : *CHANNELVOICE 8 TubaGb
   tun%(8) = -929
WHEN "BassDrum" : *CHANNELVOICE 8 BassDrum
   tun%(8) = -4000
WHEN "HiHat" : *CHANNELVOICE 8 HiHat
   tun%(8) = -4000
WHEN "OrcHit" : *CHANNELVOICE 8 OrcHit
   tun%(8) = -4085
WHEN "Piano" : *CHANNELVOICE 8 Piano
   tun%(8) = -4171
WHEN "Sax" : *CHANNELVOICE 8 Sax
   tun%(8) = -4085
WHEN "Snare" : *CHANNELVOICE 8 Snare
   tun%(8) = -8096
WHEN "Choir1" : *CHANNELVOICE 8 Choir1
   tun%(8) = -6901
WHEN "ChurOrgan" : *CHANNELVOICE 8 ChurOrgan
   tun%(8) = -6901
WHEN "Opera" : *CHANNELVOICE 8 Opera
   tun%(8) = -13387
WHEN "OrchChoir" : *CHANNELVOICE 8 OrchChoir
   tun%(8) = -6133
WHEN "OrganHit" : *CHANNELVOICE 8 OrganHit
   tun%(8) = -5024
WHEN "AgogoAfric" : *CHANNELVOICE 8 AgogoAfric
   tun%(8) = -6219
WHEN "AgogoBrazi" : *CHANNELVOICE 8 AgogoBrazi
   tun%(8) = -10997
WHEN "AgogoWood" : *CHANNELVOICE 8 AgogoWood
   tun%(8) = -13728
WHEN "BDGatedRev" : *CHANNELVOICE 8 BDGatedRev
   tun%(8) = -5877
WHEN "BDMarching" : *CHANNELVOICE 8 BDMarching
   tun%(8) = -8608
WHEN "BDPiloMute" : *CHANNELVOICE 8 BDPiloMute
   tun%(8) = -7072
WHEN "Cabasa" : *CHANNELVOICE 8 Cabasa
   tun%(8) = -7072
WHEN "Cachichi1" : *CHANNELVOICE 8 Cachichi1
   tun%(8) = -4000
WHEN "CachichiTr" : *CHANNELVOICE 8 CachichiTr
   tun%(8) = -8096
WHEN "Castanets" : *CHANNELVOICE 8 Castanets
   tun%(8) = -4000
WHEN "CongaMid" : *CHANNELVOICE 8 CongaMid
   tun%(8) = -4171
WHEN "CongaSmCl" : *CHANNELVOICE 8 CongaSmCl
   tun%(8) = -4683
WHEN "CymbalCrsh" : *CHANNELVOICE 8 CymbalCrsh
   tun%(8) = -4000
WHEN "CymRideBel" : *CHANNELVOICE 8 CymRideBel
   tun%(8) = -16288
WHEN "CymRStRoll" : *CHANNELVOICE 8 CymRStRoll
   tun%(8) = -6389
WHEN "CymSplshCa" : *CHANNELVOICE 8 CymSplshCa
   tun%(8) = -9120
WHEN "Flexitone" : *CHANNELVOICE 8 Flexitone
   tun%(8) = -8096
WHEN "GongSoft" : *CHANNELVOICE 8 GongSoft
   tun%(8) = -5365
WHEN "Gonza1" : *CHANNELVOICE 8 Gonza1
   tun%(8) = -12192
WHEN "GuiroSlow" : *CHANNELVOICE 8 GuiroSlow
   tun%(8) = -6048
WHEN "HandClaps" : *CHANNELVOICE 8 HandClaps
   tun%(8) = -4000
WHEN "HiHatFoot" : *CHANNELVOICE 8 HiHatFoot
   tun%(8) = -6389
WHEN "Maracas1" : *CHANNELVOICE 8 Maracas1
   tun%(8) = -8096
WHEN "MarimbaSB3" : *CHANNELVOICE 8 MarimbaSB3
   tun%(8) = -4000
WHEN "Ratchet" : *CHANNELVOICE 8 Ratchet
   tun%(8) = -6731
WHEN "RotoTomRev" : *CHANNELVOICE 8 RotoTomRev
   tun%(8) = -6133
WHEN "SimmonsBD1" : *CHANNELVOICE 8 SimmonsBD1
   tun%(8) = -8096
WHEN "SimmonsSn1" : *CHANNELVOICE 8 SimmonsSn1
   tun%(8) = -5707
WHEN "SleighBell" : *CHANNELVOICE 8 SleighBell
   tun%(8) = -4000
WHEN "SuperGong" : *CHANNELVOICE 8 SuperGong
   tun%(8) = -4341
WHEN "SynthSnare" : *CHANNELVOICE 8 SynthSnare
   tun%(8) = -4000
WHEN "SynTom" : *CHANNELVOICE 8 SynTom
   tun%(8) = -9120
WHEN "TimpCresBb" : *CHANNELVOICE 8 TimpCresBb
   tun%(8) = -5962
WHEN "TimpLowBb" : *CHANNELVOICE 8 TimpLowBb
   tun%(8) = -5707
WHEN "TimpRollEb" : *CHANNELVOICE 8 TimpRollEb
   tun%(8) = -4000
WHEN "TomRoll" : *CHANNELVOICE 8 TomRoll
   tun%(8) = -4000
WHEN "ToyHooter" : *CHANNELVOICE 8 ToyHooter
   tun%(8) = -9717
WHEN "ToyWhistle" : *CHANNELVOICE 8 ToyWhistle
   tun%(8) = -4000
 ENDCASE
 ENDCASE
 :
 ELSE
  *CHANNELVOICE 1 WaveSynth-Beep
  *CHANNELVOICE 2 WaveSynth-Beep
  *CHANNELVOICE 3 WaveSynth-Beep
  *CHANNELVOICE 4 WaveSynth-Beep
  *CHANNELVOICE 5 WaveSynth-Beep
  *CHANNELVOICE 6 WaveSynth-Beep
  *CHANNELVOICE 7 WaveSynth-Beep
  *CHANNELVOICE 8 WaveSynth-Beep
 ENDIF
  :
  REM fill bar%() with starting bar nos for each voice
  PROCnewnotereception((vnumber%-1),startingbar%,startbeat%,0,0,0,0,0,0)
  CASE option% OF
   WHEN 1,3 : startcell% = 0
   WHEN 2 : startcell% = numusedcells%(vnumber%-1)
   WHEN 4 : start% = (startingbar%*10^3)+startbeat%
            voice% = vnumber%-1 : PROCsearch(start%)
  ENDCASE
  cell%(vnumber%-1) = startcell%
  bar%(vnumber%-1) = array%(cell%(vnumber%-1),0,vnumber%-1)DIV10^6
 NEXT
 :
 startbar% = startingbar% : preplaydisplay$ = "y" : PROCdisplay : preplaydisplay$ = "n"
 tempo% = tempi%(startingbar%)*960*0.681595
 IF waveload$ = "done" THEN tempo% = tempo%*1.23065
 TEMPO tempo%
 kount% = 1
 :
 FOR barnum% = startingbar% TO endbar%
 :
 IF playnewscreen$ = "y" AND ((startbar%+(numbars%*2)) <= nobars%) THEN
 IF barnum% = startingbar% + (numbars%*kount%) + 1 THEN
  startbar% += numbars% : preplaydisplay$ = "y" : PROCdisplay: kount% += 1
  preplaydisplay$ = "n"
 ENDIF
 ENDIF
 :
 tempo% = tempi%(barnum%-1)*960*0.681595
 IF waveload$ = "done" THEN tempo% = tempo%*1.23065
 TEMPO tempo%
  REPEAT UNTIL BEAT < 20
 :
 FOR count% = 1 TO nvoices%
  voicenum% = playvoices%(count%)-1
  lv$ = "n"
  IF lvdata%(count%,1)>0 THEN lv$ = "y"
 :
 WHILE bar%(voicenum%) = barnum%
 after% = ((array%(cell%(voicenum%),0,voicenum%) DIV 10^3) MOD 10^3) + 20
 pitchdata% = (array%(cell%(voicenum%),0,voicenum%)MOD10^3)
 notename% = pitchdata% DIV 100
 accid% = (pitchdata% MOD 100) DIV 10
 octave% = pitchdata%MOD10
 inflect% = (array%(cell%(voicenum%),2,voicenum%)MOD10^2) : inflect% -= 50
 :
 CASE notename% OF
  WHEN 6 : pitch% = 3755
  WHEN 5 : pitch% = 3072
  WHEN 4 : pitch% = 2389
  WHEN 3 : pitch% = 1707
  WHEN 2 : pitch% = 1365
  WHEN 1 : pitch% = 683
  WHEN 0 : pitch% = 0
 ENDCASE
 accid% = accid%-5
 accid% = accid%*85.34
 pitch% = pitch% + accid%
 pitch% = pitch% + (4096*octave%) + tun%(count%) + (inflect%*3.41)
 amp2% = (array%(cell%(voicenum%),2,voicenum%)DIV10^2)MOD10
 amp3% = (array%(cell%(voicenum%),2,voicenum%)DIV10^3)MOD10
 :
 dyn% = array%(cell%(voicenum%),1,voicenum%)MOD10
 dyn% = 257 + (16*dyn%)
 IF amp2% = 9 AND amp3% <> 0 THEN
  CASE amp3% OF
   WHEN 1 : dyn% += 1
   WHEN 2 : dyn% += 2
   WHEN 3 : dyn% += 4
   WHEN 4 : dyn% += 6
   WHEN 5 : dyn% += 8
   WHEN 6 : dyn% += 10
   WHEN 7 : dyn% += 12
   WHEN 8 : dyn% += 14
   WHEN 9 : dyn% += 15
  ENDCASE
 ENDIF
 IF dyn% > 383 THEN dyn% = 383
 :
 dur% = (array%(cell%(voicenum%),1,voicenum%)MOD10^4)DIV10
 IF waveload$ = "done" THEN dur% = dur%/1.23065
 IF dur% < 1 THEN dur% = 1
  IF lv$ = "n" THEN
   chan% = count%
  ELSE
   tic%(count%)+=1
   IF lvdata%(count%,tic%(count%)) = 0 THEN tic%(count%) = 1
   chan% = lvdata%(count%,tic%(count%))
  ENDIF
  :
  SOUND chan%, dyn%, pitch%, dur%, after%
  :
  IF amp2% <> 9 THEN PROCenv
  :
 cell%(voicenum%) += 1
 bar%(voicenum%) = array%(cell%(voicenum%),0,voicenum%) DIV 10^6
 :
 ENDWHILE
 :
 NEXT count%
 :
 REPEAT UNTIL BEAT > 20
:
 NEXT barnum%
 :
 PROCpostdisplay
 :
 ENDPROC
 :
 REM*******************************
 :
 DEF PROCaddonenote
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,72,72,55) ELSE PROCwindow(20,69,60,42)
 CLS
 INPUT' " Which voice "voice%
 IF voice% = 0 THEN PROCpressenter
 voice% -= 1
 INPUT '" Bar number "barno%
 IF barno% = 0 THEN barno% = 1
 INPUT '" Beat number "beats%
 PROCalterbeats
 beatno% = beats%
 :
 PRINT '" Pitch name ";
 COLOUR 3
 CASE GET$ OF
  WHEN "C","c" : note% = 0 : PRINT "C"
  WHEN "D","d" : note% = 1 : PRINT "D"
  WHEN "E","e" : note% = 2 : PRINT "E"
  WHEN "F","f" : note% = 3 : PRINT "F"
  WHEN "G","g" : note% = 4 : PRINT "G"
  WHEN "A","a" : note% = 5 : PRINT "A"
  WHEN "B","b" : note% = 6 : PRINT "B"
 ENDCASE
 COLOUR 0
 PRINT '" Accidental ";

 COLOUR 3
 CASE GET$ OF
  WHEN "1" : accid% = 1 : PRINT "flat"
  WHEN "2" : accid% = 2 : PRINT "3/8flat"
  WHEN "3" : accid% = 3 : PRINT "1/4flat"
  WHEN "4" : accid% = 4 : PRINT "1/8flat"
  WHEN "5" : accid% = 5 : PRINT "nat"
  WHEN "6" : accid% = 6 : PRINT "1/8shrp"
  WHEN "7" : accid% = 7 : PRINT "1/4shrp"
  WHEN "8" : accid% = 8 : PRINT "3/8shrp"
  WHEN "9" : accid% = 9 : PRINT "shrp"
 ENDCASE
 COLOUR 0
 PRINT '" octave ";
 COLOUR 3
 CASE GET$ OF
  WHEN "0" : octave% = 0 : PRINT "0"
  WHEN "1" : octave% = 1 : PRINT "1"
  WHEN "2" : octave% = 2 : PRINT "2"
  WHEN "3" : octave% = 3 : PRINT "3"
  WHEN "4" : octave% = 4 : PRINT "4"
  WHEN "5" : octave% = 5 : PRINT "5"
  WHEN "6" : octave% = 6 : PRINT "6"
  WHEN "7" : octave% = 7 : PRINT "7"
  WHEN "8" : octave% = 8 : PRINT "8"
 ENDCASE
 COLOUR 0
 pitch% = (note%*100)+(accid%*10)+octave%
  PRINT '" Duration "
  INPUT '"   bars "b%
  INPUT '"   beats "beats% : PROCalterbeats
 dur% = (b%*960)+beats%
:
CLS
:
PRINT'" Envelope/glissando has how many phases? "
INPUT'" (if no envelope/glissando type 0) "numphases%
:
CASE numphases% OF
:
WHEN 0 :
INPUT'" Ampitude is "amp$ : PROCconvertdynamics : amp1% = amp%
 ph2% = 0 : ph1% = 0 : amp4% = 0 : amp3% = 0 : amp2% = 9 : gliss3% = 10 : gliss2% = 50 : gliss1% = 50
:
WHEN 1 :
 INPUT'" starting amplitude is "amp$ : PROCconvertdynamics : amp1% = amp%
 INPUT'" destination amplitude is "amp$ : PROCconvertdynamics : amp2% = amp%
 IF amp2% = amp1% THEN amp2% = 0
 INPUT'" glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss1% = 50-gliss%
 ph2% = 0 : ph1% = 0 : amp4% = 0 : amp3% = 0 : gliss3% = 10 : gliss2% = 50
:
WHEN 2 :
 INPUT'" starting amplitude is "amp$ : PROCconvertdynamics : amp1% = amp%
 PRINT'" phase 1 ends after what percentage "
 INPUT " of the note's duration "ph1%
 INPUT' " phase 1's destination amplitude is "amp$ : PROCconvertdynamics : amp2% = amp%
 INPUT' " phase 1's glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss1% = 50-gliss%
 INPUT'" phase 2's destination amplitude is "amp$ : PROCconvertdynamics : amp3% = amp%
 INPUT '" phase 2's glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss2% = 50-gliss%
 ph2% = 0 : amp4% = 0 : gliss3% = 10
:
WHEN 3 :
 INPUT'" starting amplitude is "amp$ : PROCconvertdynamics : amp1% = amp%
 PRINT'" phase 1 ends after what percentage "
 INPUT " of the note's duration "ph1%
 INPUT '" phase 1's destination amplitude is "amp$ : PROCconvertdynamics : amp2% = amp%
 INPUT '" phase 1's glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss1% = 50-gliss%
 PRINT'" phase 2 ends after what percentage "
 INPUT " of the note's duration "ph2%
 INPUT'" phase 2's destination amplitude is "amp$ : PROCconvertdynamics : amp3% = amp%
 INPUT '" phase 2's glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss2% = 50-gliss%
 INPUT'" phase 3's destination amplitude is "amp$ : PROCconvertdynamics : amp4% = amp%
REPEAT
INPUT '" phase 3's glissando is (in 1/8 tones, max 10,-10) "gliss%
 gliss3% = 10-gliss%
IF gliss3% > 20 THEN VDU7
IF gliss3% < 0 THEN VDU7
UNTIL gliss3% < 21 AND gliss3% >= 0
:
ENDCASE
:
 env% = (ph2%*10^5)+(ph1%*10^3)+(amp4%*10^2)+(amp3%*10)+amp2%
 dyn% = amp1%
 gliss% = (gliss3%*10^4)+(gliss2%*10^2)+gliss1%
:
PRINT '" Microtonal inflection "
 INPUT'" (in cents, eg 1, -1, etc., max.49) "inf%
 inf% = 50+inf%
 :
 addingnotes$ = "y"
 PROCnewnotereception(voice%,barno%,beatno%,pitch%,dyn%,env%,dur%,gliss%,inf%)
 :
 PROCdisplay
 :
 ENDPROC
 :
 REM*************************************
 :
 DEF PROCinsertattacks
 :
 IF copymove$ = "C" OR copymove$ = "EC" THEN PROCundoprepare
 :
 destinationdone$ = "n"
 :
 CASE savevoice$ OF
  WHEN "Y" : PROCsavevoice
  OTHERWISE
 ENDCASE
 REM PROCwindow(20,69,70,55)
 CLS
 repeatposit$ = "n"
 IF method$ = "raw" THEN
  IF reordered$ = "n" THEN
  IF equalized$ = "n" THEN
   IF quiz$ = "yes" THEN
    IF copyit$ = "ON" THEN
     :
     IF copydownwards$ = "n" THEN
      PRINT ' " the passage is to start at "
      INPUT ' " bar "bars%
       IF bars% <> 0 THEN memorybar% = bars%
       IF bars% = 0 THEN
       bars% = holdbar% : beats% = holdbeat% : repeatposit$ = "y"

IF askprevious$ = "y" THEN
thing$ = INKEY$(50)
IF thing$ <> "" THEN
bars% = memorybar% : beats% = memorybeat%
COLOUR 3
PRINT'" bar ";bars%;" beat ";beats%;"?"
COLOUR 0
PRINT '" (for OK press 0, if not OK press X) "
destinationdone$ = "y"
CASE GET$ OF
 WHEN "X","x" : PROCinsertattacks
 OTHERWISE
ENDCASE
ENDIF
ENDIF

       ENDIF
     ELSE bars% = holdbar% : beats% = holdbeat% : repeatposit$ = "y"
     :
     ENDIF
     :
    ELSE
     :
    PRINT' " the passage is to start at "
    INPUT' " bar "bars%
      IF bars% = 0 THEN
       bars% = startbar%
       COLOUR 3 : PRINT' bars% : COLOUR 0
       nothing$ = INKEY$(100)
      ENDIF
    :
    ENDIF : REM copyit$
    :
    IF repeatposit$ = "n" THEN
    INPUT' " beat "beats%
    :
     memorybeat% = beats%
    ELSE
    :
     IF copydownwards$ = "n" AND destinationdone$ = "n" THEN
      COLOUR 3
      PRINT'" bar ";bars%;" beat ";beats%;"?"
      COLOUR 0
      PRINT'" (press 0 for OK, B for Back"
      PRINT "  F for Forward, X if not OK)"
      CASE GET$ OF
       WHEN "b", "B" : PROCmoveback
       WHEN "f", "F" : PROCmoveforward
       WHEN "x","X" : PROCinsertattacks
      OTHERWISE
      ENDCASE
     ELSE
     ENDIF
    :
    ENDIF : REM repeatposit$
    :
   ELSE
    bars% = funcbar% : beats% = funcbeat%
   ENDIF : REM quiz$
    :
   quiz$ = "yes"
   PROCalterbeats
   startat% = (bars%*(10^3))+beats%
  ENDIF : REM equalized$
  ENDIF : REM reordered$
  :
 reordered$ = "n" : equalized$ = "n"
 :
 attacks2%() = attacks1%()
 :
 attacks2%() = attacks2%() + (startat% MOD 10^3) : REM moves attacks further up bar, if necc
 :
 attacks3%() = attacks2%()
 FOR count% = 0 TO (manyattacks%-1)
  attacks3%(count%) = attacks3%(count%) DIV 960
 NEXT
 REM gives list of bar mos starting at 0
 :
 attacks3%() = attacks3%() * 960
 attacks2%() = attacks2%() - attacks3%()
 attacks3%() = attacks3%() / 960
 REM list of actual beat numbers
 :
 attacks3%() = attacks3%() + (startat% DIV 10^3) : REM list of actual bar nos
 :
 attacks3%() = attacks3%()*(10^3)
 attacks2%() = attacks2%() + attacks3%()
 REM list of actual bar/beat numbers
 :
 ENDIF : REM method$
 :
 : IF method$ <> "alreadyrhythmicized" THEN rhythmicized$ = "n"
 IF seeinfo$ = "y" THEN
 :
 IF printinfo$ = "y" THEN PROCprintattacks
 durat% = 0
 PROCwindow(10,60,90,5)
 VDU 14
 PRINT '" The group of attacks will be at "
 PRINT"  "
 PRINT TAB(8) "ATTACKS AT";
 PRINT TAB(30) "DURATIONS";
 PRINT TAB(54) "RATIOS"
 FOR count% = 0 TO (manyattacks%-1)
  COLOUR 3 : PRINT TAB(1)(attacks2%(count%))DIV10^3;" ";
  COLOUR 0 : PRINT ;(attacks2%(count%))MOD10^3;
 IF count% > 0 THEN
  durat1% = durat%
  durat% = (attacks2%(count%)MOD10^3)-(attacks2%(count%-1)MOD10^3)
 addon% = ((attacks2%(count%)DIV(10^3))-(attacks2%(count%-1)DIV(10^3)))*960
 durat% = durat% + addon%
  PRINT TAB(26) durat%;
  IF count%>1 THEN
 IF direction$ = "rit" THEN ratio = durat%/durat1% ELSE ratio = durat1%/durat%
 CASE ratio OF
  WHEN 0.5 : PRINT TAB(52) "0.5"
  WHEN 1.0 : PRINT TAB(52) "1.0"
  WHEN 1.5 : PRINT TAB(52) "1.5"
  WHEN 2.0 : PRINT TAB(52) "2.0"
  WHEN 2.5 : PRINT TAB(52) "2.5"
  OTHERWISE PRINT TAB(52) ratio
 ENDCASE
  ENDIF
 ENDIF
 NEXT
 :
 VDU 15
 :
 ENDIF : REM seeinfo
 :
 IF method$ = "raw" THEN
 IF seereordery$ = "y" THEN
  PRINT'" Do you want this group to be re-ordered?"
  PRINT'" (Y/1 = yes, any other key = no) "
  :
  CASE GET$ OF
   WHEN "Y","y","1" : PROCreorderattacks
   OTHERWISE
  ENDCASE
 seereordery$ = "n"
 rhythmicized$ = "n"
 ENDIF
 IF seeequalizey$ = "y" THEN
 PRINT'" Do you want to equalize any durations? "
 PRINT'" (Y/0/1 = yes, N/2 = no) "
  CASE GET$ OF
   WHEN "n","N","2" :
   OTHERWISE PROCequalizedurats
  ENDCASE
 seeequalizey$ = "n"
 ENDIF
 IF seerhythmicize$ = "y" THEN
 PRINT'" Do you want this group to be rhythmicized? "
 CASE GET$ OF
  WHEN "Y","y" : PROCprerhythmicize
 rhythmicized$ = "y"
  OTHERWISE
 ENDCASE
 ENDIF
 ENDIF : REM method$ = raw?
 IF seequery$ = "y" THEN
 PRINT ' " Do you want to add this group to the array? "
 CASE GET$ OF
  WHEN "N","n" : PROCdisplay : REM attacks1%() remains intact until a new group of attacks is defined with PROCseriesattacks, and so may be add to array anywhere else
  OTHERWISE
 ENDCASE
 ENDIF : REM seequery
 :
 IF displayedfunc$ = "n" THEN

  :
  IF copydownwards$ = "n" THEN
   IF screenvoices$ = "n" THEN
  :
  IF copysuccessively$ = "y" THEN
   INPUT' " Which voice "voice%
   IF voice% <> 0 THEN succto% = voice% ELSE PROCpressenter
  ELSE
   INPUT'" Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ENDIF : REM copysuccessively$
   :
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
  ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN
   IF copysuccessively$ = "n" THEN
    voice% = samevoice%
   ELSE
    voice% = succto%-1
   ENDIF : REM copysucc
  ENDIF : REM if voice = -1
  :
  ELSE voice% = displayvoices%(startv%+downby%) : voice% = voice%-1
  ENDIF
  :
 ENDIF
 :
 IF copyit$ = "OFF" THEN
 IF paraset$ = "on" THEN
 PRINT'" Do you want to (re)define the values assigned "
 PRINT " to each parameter when inputting a group of "
 PRINT " attacks, use defaults or reset defaults? "
 PRINT " (press Y/N/D/R)"
 PRINT'" - press M/V/D/P again to go back to always "
 PRINT "  using the assigned values without asking "
 CASE GET$ OF
  WHEN "R","r" : resetdefaults$ = "y"
  PRINT'" Please press the same key again to proceed"
  OTHERWISE
  PRINT'" Please press the same key again to proceed"
 ENDCASE
 :
 CASE GET$ OF
  WHEN "Y","y","R","r" :
   CLS : parasdefined$ = "yes" : PRINT' " all at pitch name ";
   COLOUR 3
   CASE GET$ OF
    WHEN "C","c" : note% = 0 : PRINT "C"
    WHEN "D","d" : note% = 1 : PRINT "D"
    WHEN "E","e" : note% = 2 : PRINT "E"
    WHEN "F","f" : note% = 3 : PRINT "F"
    WHEN "G","g" : note% = 4 : PRINT "G"
    WHEN "A","a" : note% = 5 : PRINT "A"
    WHEN "B","b" : note% = 6 : PRINT "B"
  ENDCASE
 COLOUR 0
  PRINT "        accidental ";

 COLOUR 3
  CASE GET$ OF
   WHEN "1" : accid% = 1 : PRINT "flat"
   WHEN "2" : accid% = 2 : PRINT "3/8flat"
   WHEN "3" : accid% = 3 : PRINT "1/4flat"
   WHEN "4" : accid% = 4 : PRINT "1/8flat"
   WHEN "5" : accid% = 5 : PRINT "nat"
   WHEN "6" : accid% = 6 : PRINT "1/8shrp"
   WHEN "7" : accid% = 7 : PRINT "1/4shrp"
   WHEN "8" : accid% = 8 : PRINT "3/8shrp"
   WHEN "9" : accid% = 9 : PRINT "shrp"
  ENDCASE
 COLOUR 0
  PRINT "        octave ";
 COLOUR 3
   CASE GET$ OF
    WHEN "0" : octave% = 0 : PRINT "0"
    WHEN "1" : octave% = 1 : PRINT "1"
    WHEN "2" : octave% = 2 : PRINT "2"
    WHEN "3" : octave% = 3 : PRINT "3"
    WHEN "4" : octave% = 4 : PRINT "4"
    WHEN "5" : octave% = 5 : PRINT "5"
    WHEN "6" : octave% = 6 : PRINT "6"
    WHEN "7" : octave% = 7 : PRINT "7"
    WHEN "8" : octave% = 8 : PRINT "8"
   ENDCASE
 COLOUR 0
  pitchset%(voice%) = (note%*100)+(accid%*10)+octave%

IF resetdefaults$ = "y" THEN
 FOR count% = 0 TO (numparts%-1)
  pitchset%(count%) = pitchset%(voice%)
 NEXT
ENDIF

 INPUT " all at duration:  bars "b%
 INPUT "                   beats "beats% : PROCalterbeats
 dur% = (b%*960)+beats%
 durset%(voice%) = dur%

IF resetdefaults$ = "y" THEN
 FOR count% = 0 TO (numparts%-1)
  durset%(count%) = durset%(voice%)
 NEXT
ENDIF
 :
 INPUT " all at amplitude "amp$
 CASE amp$ OF
  WHEN "0"     : ampset%(voice%) = 0
  WHEN "ppp"     : ampset%(voice%) = 1
  WHEN "pp"     : ampset%(voice%) = 2
  WHEN "p"     : ampset%(voice%) = 3
  WHEN "mp"     : ampset%(voice%) = 4
  WHEN "mf"     : ampset%(voice%) = 5
  WHEN "f"     : ampset%(voice%) = 6
  WHEN "ff"     : ampset%(voice%) = 7
  WHEN "fff"     : ampset%(voice%) = 8
 ENDCASE

IF resetdefaults$ = "y" THEN
 FOR count% = 0 TO (numparts%-1)
  ampset%(count%) = ampset%(voice%)
 NEXT
ENDIF
  :
 INPUT " all at microtonal inflection (in cents: 1,-1 etc) [max 49,-49]: "infset%
 infset%(voice%) = 50+infset%
 envset%(voice%) = 9
 glissset%(voice%) = 105050
 resetdefaults$ = "n"
  WHEN "D","d" : pitchset%(voice%) = 55
                 ampset%(voice%) = 6
                 envset%(voice%) = 9
                 durset%(voice%) = 319
                 glissset%(voice%) = 105050
                 infset%(voice%) = 50
 OTHERWISE
 ENDCASE
 ENDIF
 ENDIF
 :
 addingnotes$ = "y"
 IF copyit$ = "OFF" THEN
 IF rhythmicized$ = "n" THEN
 FOR counter% = 0 TO (manyattacks%-1)
  PROCnewnotereception(voice%,(attacks2%(counter%)DIV10^3), (attacks2%(counter%) MOD 10^3), pitchset%(voice%), ampset%(voice%), envset%(voice%), durset%(voice%), glissset%(voice%), infset%(voice%))
 NEXT
 ELSE
 FOR counter% = 0 TO (manyattacks%-1)
  PROCnewnotereception(voice%,(attacks5%(counter%)DIV10^3), (attacks5%(counter%) MOD 10^3), pitchset%(voice%), ampset%(voice%), envset%(voice%), durset%(voice%), glissset%(voice%), infset%(voice%))
 NEXT
 PROCdisarrayfill
 ENDIF
 ELSE
  IF rhythmicized$ = "n" THEN
   FOR counter% = 0 TO (manyattacks%-1)
    PROCnewnotereception(voice%, (attacks2%(counter%)DIV10^3), (attacks2%(counter%)MOD10^3), pitches%(counter%), amplitudes%(counter%), envelopes%(counter%), durations%(counter%), glissandos%(counter%), inflections%(counter%))
   NEXT
   ELSE
    FOR counter% = 0 TO (manyattacks%-1)
     PROCnewnotereception(voice%, (attacks5%(counter%)DIV10^3), (attacks5%(counter%)MOD10^3), pitches%(counter%), amplitudes%(counter%), envelopes%(counter%), durations%(counter%), glissandos%(counter%), inflections%(counter%))
    NEXT
    PROCdisarrayfill
   ENDIF
 :
  ENDIF
 :

 copyit$ = "OFF" : displayedfunc$ = "n" : copydownwards$ = "n" : justone$ = "n"
 quickextract$ = "n"
 PROCdisplay
 :
 ENDPROC
 :
 REM*********************************************
 :
 DEF PROCseriespitches
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,69,60,55) ELSE PROCwindow(20,69,60,42)
 :
 IF usebottomstave$ = "n" THEN
 :
  IF singlepitch$ = "m" THEN




IF firstpitch$ = "y" THEN
 INPUT' " How many pitches "numpitches%
ELSE


PRINT' " How many pitches "
PRINT'  " for "; prevnumpitches%;
INPUT  " press 0 twice) "numpitches%
IF numpitches% = 0 THEN
wait$ = INKEY$(50)
IF wait$ <> "" THEN numpitches% = prevnumpitches%
ENDIF


ENDIF




  ELSE
   numpitches% = 1
  ENDIF
 :
 ELSE
 numpitches% = howmany%
 ENDIF
 :
 IF numpitches% = 0 THEN numpitches% = 1
 IF numpitches% > 1 THEN
 :
 IF askaboutpitches$ = "y" THEN
   PRINT'" Are the pitches all the same?"
   PRINT'" (0/1 count as yes, 2 counts as no) "
   CASE GET$ OF
     WHEN "N","n","2" :
     OTHERWISE PROCsamepitches
   ENDCASE
  ELSE PROCsamepitches
  ENDIF
 :
 ENDIF
 :
 FOR count% = 0 TO numpitches% - 1
  PRINT' " Note name for pitch ";count%+1;" is ";
 COLOUR 3
  CASE GET$ OF
   WHEN "C","c" : note% = 0 : PRINT "C"
   WHEN "D","d" : note% = 1 : PRINT "D"
   WHEN "E","e" : note% = 2 : PRINT "E"
   WHEN "F","f" : note% = 3 : PRINT "F"
   WHEN "G","g" : note% = 4 : PRINT "G"
   WHEN "A","a" : note% = 5 : PRINT "A"
   WHEN "B","b" : note% = 6 : PRINT "B"
  ENDCASE
 COLOUR 0
  PRINT' "               accidental ";

 COLOUR 3
  CASE GET$ OF
   WHEN "1" : accid% = 1 : PRINT "flat"
   WHEN "2" : accid% = 2 : PRINT "3/8flat"
   WHEN "3" : accid% = 3 : PRINT "1/4flat"
   WHEN "4" : accid% = 4 : PRINT "1/8flat"
   WHEN "5" : accid% = 5 : PRINT "nat"
   WHEN "6" : accid% = 6 : PRINT "1/8shrp"
   WHEN "7" : accid% = 7 : PRINT "1/4shrp"
   WHEN "8" : accid% = 8 : PRINT "3/8shrp"
   WHEN "9" : accid% = 9 : PRINT "shrp"
  ENDCASE
 COLOUR 0
  PRINT '"                   octave ";
 COLOUR 3
  CASE GET$ OF
   WHEN "0" : octave% = 0 : PRINT "0"
   WHEN "1" : octave% = 1 : PRINT "1"
   WHEN "2" : octave% = 2 : PRINT "2"
   WHEN "3" : octave% = 3 : PRINT "3"
   WHEN "4" : octave% = 4 : PRINT "4"
   WHEN "5" : octave% = 5 : PRINT "5"
   WHEN "6" : octave% = 6 : PRINT "6"
   WHEN "7" : octave% = 7 : PRINT "7"
   WHEN "8" : octave% = 8 : PRINT "8"
  ENDCASE
 COLOUR 0
 pitches%(count%) = (note%*100)+(accid%*10)+octave%
 NEXT
 :
 prevnumpitches% = numpitches% : firstpitch$ = "n"
 REM function can feed pitches similarly into pitches%
 :
 PROCinsertpitches
 :
 ENDPROC
 :
 REM************************************************
 :
 DEF PROCinsertpitches
 :
 CLS
 :
IF reorderpitches$ = "y" THEN
PRINT'" Do you want to randomly re-order"
PRINT " the pitches (0 = yes, 2 = no)"
CASE GET$ OF
WHEN "2" :
OTHERWISE
CLS
PRINT'" Randomly reorder pitches in batches of "
INPUT " between how many (0 = previous) "low%
IF low% = 0 THEN
 low% = previouslow%
 COLOUR 3
 PRINT low%
 COLOUR 0
 wait$ = INKEY$(50)
ENDIF
INPUT'" and how many "high%
IF high% = 0 THEN
high% = previoushigh%
COLOUR 3
PRINT high%
COLOUR 0
wait$ = INKEY$(50)
ENDIF
:
startingcell% = 0
pitches1%() = 0
pitches2%() = 0
pitches1%() = pitches%()
REPEAT
diff% = high%-low%
batchsize% = RND(diff%+1)-1
batchsize% += low%
counter% = 0
REPEAT
cell% = RND(batchsize%)
cell% = startingcell% + cell% - 1
IF pitches1%(cell%) <> 0 THEN
pitches2%(startingcell%+counter%) = pitches1%(cell%)
counter% += 1
ENDIF
pitches1%(cell%) = 0
check% = 0
FOR count% = 1 TO batchsize%
check% += pitches1%(startingcell%+count%-1)
NEXT
UNTIL check% = 0
startingcell% += batchsize%
UNTIL (numpitches%-high%) < startingcell%
FOR count% = 0 TO numpitches%-1
IF pitches2%(count%) <> 0 THEN
pitches%(count%) = pitches2%(count%)
ENDIF
NEXT
previouslow% = low%
previoushigh% = high%
ENDCASE
ENDIF : REM reorderpitches$
:
 repeatposit$ = "n"
IF seequery$ = "y" THEN
 PRINT ' " Do you want to read these pitches "
 PRINT   " into the array? "
 CASE GET$ OF
  WHEN "N","n" : PROCdisplay : REM pitches% remains intact
  OTHERWISE
 ENDCASE
ENDIF : REM seequery$
 :
IF usebottomstave$ = "n" THEN
  IF screenvoices$ = "n" THEN
   :
   IF copysuccessively$ = "n" THEN
    INPUT'' " Which voice? "voice%
    IF voice% = 0 THEN PROCpressenter
    ELSE PROCcopysuccessively
    ENDIF
    :
  ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  ENDIF : REM usebottomstave$
  :
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  IF usebottomstave$ = "y" THEN voice% = displayvoices%(startv%+2)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
  :
IF usebottomstave$ = "n" THEN
:
IF quickcopy$ = "y" THEN
INPUT ' " starting at note number "along%
IF along% = 0 THEN along% = 1
 along%-=1
 bars% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
 beats% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  holdbar% = bars%
  holdbeat% = beats%
PROCalterbeats
 startat% = (bars%*(10^3))+beats%
:
ELSE
:
INPUT'" Starting at bar number "bars%
IF bars% = 0 THEN
 bars% = holdbar% : beats% = holdbeat% : repeatposit$ = "y"
ENDIF
 holdbar% = bars%
IF repeatposit$ = "y" THEN
PRINT'" bar ";bars%;" beat ";beats%;"?"
PRINT'" (for OK press 0, if not OK press X)"
CASE GET$ OF
 WHEN"X","x" : PROCinsertpitches
 OTHERWISE
ENDCASE
ELSE
 INPUT " beat "beats%
 holdbeat% = beats%
ENDIF
 PROCalterbeats
 startat% = (bars%*(10^3))+beats%
:
ENDIF : REM quickcopy$
:
ELSE
along% = 0
 bars% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
 beats% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  holdbar% = bars%
  holdbeat% = beats%
PROCalterbeats
 startat% = (bars%*(10^3))+beats%
:
ENDIF : REM usebottomstave$
 :
 PROCsearch(startat%)
 shunt$ = "N"
 :
 endcell% = startcell% + numpitches% -1
 IF endcell% >= numusedcells%(voice%) THEN endcell% = numusedcells%(voice%)-1
 FOR count% = startcell% TO endcell%
  PROCcellfill(count%,voice%,999,999,(pitches%(count%-startcell%)),9,999,999,99,99)
 NEXT
 :
 PROCdisplay
 :
 ENDPROC
 :
 REM*************************************************
 :
 DEF PROCfunctionprelude
 :
IF seereorderx$ = "y" THEN seereordery$ = "y"
IF seeequalizex$ = "y" THEN seeequalizey$ = "y"
:
IF easiermenus$ = "n" THEN PROCwindow(20,69,60,55) ELSE PROCwindow(20,69,60,42)
CLS
CASE startfinishdurats$ OF
 WHEN "N", "n" :
   INPUT' " rate "rate
 IF rate = 0 THEN rate = 1 : REM for quick inputting
 IF rate <> 1 THEN
   INPUT'" bias (for 3.7 press 0) "bias
   IF bias = 0 THEN bias = 3.7
 ENDIF
   INPUT'" number of attacks "manyattacks%



IF manyattacks% = 0 THEN manyattacks% = prevmanyattacks%
COLOUR 3 : PRINT'manyattacks% : COLOUR 0
prevmanyattacks% = manyattacks%


CASE funcinput$ OF
 WHEN "durat" :
   PRINT '" total duration... "
   INPUT' " bars "bars%
   INPUT' " beats "beats%
   PROCalterbeats
   totaldur% = (bars%*960)+beats%
 WHEN "points" :
   INPUT '" first attack at bar "funcbar%
   INPUT '"                beat "funcbeat%
   INPUT '" and last attack at bar "funcbar1%
   INPUT '"                   beat "funcbeat1%
   totaldur% = ((funcbar1%*960)+funcbeat1%)-((funcbar%*960)+funcbeat%)
 WHEN "displayed" :
   IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
:
  ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% = -1 THEN voice% = samevoice% ELSE samevoice% = voice%

IF queryalong$ = "y" THEN
INPUT' " Starting at note number "along%
IF along% = 0 THEN along% = 1
along%-=1
ENDIF


  funcbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  funcbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  funcbar1% = array%(holdstartcell%(voice%)+1+along%,0,voice%)DIV10^6
  funcbeat1% = (array%(holdstartcell%(voice%)+1+along%,0,voice%)MOD10^6)DIV10^3
  totaldur% = ((funcbar1%*960)+funcbeat1%)-((funcbar%*960)+funcbeat%)
  displayedfunc$ = "y" : along% = 0
 OTHERWISE PROCfunctionprelude
ENDCASE
   :
 result$ = "success"
 :
   PROCfunction
 IF rate <> 1 AND seegraph$ = "y" THEN
 REM PROCwindow(20,69,50,55)
 PRINT'" Do you want to see the graph? "
 CASE GET$ OF
  WHEN "Y","y" : PROCgraph
  OTHERWISE PROCfunctionpostlude
 ENDCASE
 ELSE
 PROCfunctionpostlude
 ENDIF
 ENDCASE
 :
 CASE funcinput$ OF
  WHEN "durat" :
   REM PROCwindow(20,69,69,55)
   PRINT' " total duration... "
   INPUT' "   bars "bars%
   INPUT' "   beats "beats%
   PROCalterbeats
   totaldur% = (bars%*960)+beats%
  WHEN "points" :
   REM PROCwindow(20,69,69,55)
   INPUT' " first attack at bar "funcbar%
   INPUT' "                 beat "funcbeat%
   INPUT' " and last attack at bar "funcbar1%
   INPUT' "                    beat "funcbeat1%
   totaldur% = ((funcbar1%*960)+funcbeat1%)-((funcbar%*960)+funcbeat%)
  WHEN "displayed" :
   IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
   IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
   voice% -= 1
   IF voice% = -1 THEN voice% = samevoice%
   funcbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
   funcbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
   funcbar1% = array%(holdstartcell%(voice%)+1+along%,0,voice%)DIV10^6
   funcbeat1% = (array%(holdstartcell%(voice%)+1+along%,0,voice%)MOD10^6)DIV10^3
   totaldur% = ((funcbar1%*960)+funcbeat1%)-((funcbar%*960)+funcbeat%)
   displayedfunc$ = "y" : along% = 0
  OTHERWISE PROCfunctionprelude
 ENDCASE
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,69,69,54) ELSE PROCwindow(20,69,69,42)
 :
 IF firsttimequick$ = "y" THEN
 PRINT' " quick end duration to be... "
 INPUT' "   bars "bars%
 INPUT' "   beats "beats%
 ELSE
  PRINT' " quick end duration to be how many bars "
  PRINT' " (for ";prevbars%;" press 0) "
  INPUT "   "bars%
  :
  IF bars% = 0 THEN
  COLOUR 3 : PRINT prevbars% : COLOUR 0
  ENDIF
  :
  PRINT' " and how many beats "
  PRINT' " (for ";prevbeats%;" press 0) "
  INPUT "   "beats%
  :
  IF beats% = 0 THEN
  COLOUR 3 : PRINT prevbeats% : COLOUR 0
  ENDIF
   IF bars% = 0 AND beats% = 0 THEN
    bars% = prevbars% : beats% = prevbeats%
   ENDIF
  ENDIF
 prevbars% = bars%
 prevbeats% = beats%
 PROCalterbeats
 quickend% = (bars%*960)+beats%
 :
 IF firsttimequick$ = "y" THEN
  PRINT' " slow end duration to be... "
  INPUT' "   bars "bars%
  INPUT' "   beats "beats%
 ELSE
  PRINT' " slow end duration to be how many bars "
  PRINT' " (for ";prevslowbars%;" press 0) "
  INPUT "   "bars%
  :
  IF bars% = 0 THEN
  COLOUR 3 : PRINT prevslowbars% : COLOUR 0
  ENDIF
  :
  PRINT' " and how many beats "
  PRINT' " (for ";prevslowbeats%;" press 0) "
  INPUT "   "beats%
  :
  IF beats% = 0 THEN
  COLOUR 3 : PRINT prevslowbeats% : COLOUR 0
  nothing$ = INKEY$(100)
  ENDIF
  :
   IF bars% = 0 AND beats% = 0 THEN
    bars% = prevslowbars% : beats% = prevslowbeats%
   ENDIF
  ENDIF
 prevslowbars% = bars%
 prevslowbeats% = beats%
 PROCalterbeats
 slowend% = (bars%*960)+beats%
 :
 CLS
IF firsttimequick$ = "y" THEN
 INPUT' " bias (0 = 3.7) "bias
 IF bias = 0 THEN bias = 3.7
ELSE
 PRINT' " bias "
 PRINT' " (for ";bias;" press 0) "
 INPUT' "   "newbias
 :
 IF newbias = 0 THEN
 COLOUR 3 : PRINT bias : COLOUR 0
 ELSE bias = newbias
 ENDIF
 :
ENDIF
 :
 IF firsttimequick$ = "y" THEN
 INPUT' " estimated number of attacks "manyattacks%
 ELSE
 PRINT' " estimated number of attacks "
 PRINT' " (for ";prevest%;" press 0) "
 INPUT' "   "manyattacks%
 :
 IF manyattacks% = 0 THEN
 COLOUR 3 : PRINT prevest% : COLOUR 0
 nothing$ = INKEY$(100)
 ENDIF
 :
  IF manyattacks% = 0 THEN manyattacks% = prevest%
 ENDIF
 prevest% = manyattacks%
 firsttimequick$ = "n"
 :
 rate = 5.1 : increment = 4
 increment2% = manyattacks%
 ratedir$ = "" : attacksdir$ = ""
 result$ = "noresult"
 doesitloop$ = "" : maybeloop$ = ""
  manyattacks1% = 0 : manyattacks2% = 0 : manyattacks3% = 0 : manyattacks4% = 0 : manyattacks5% = 0
 rate1=0 : rate2=0 : rate3=0 : rate4=0 : rate5=0
 testquickend1% = 0 : testslowend1% = 0
 testquickend% = 0 : testslowend% = 0
 numberoftries%=0
  goes% = 0 : goes1% = 0
 :
 REPEAT
 :
 PROCfunction
 testquickend1% = testquickend%
 testslowend1% = testslowend%
  testquickend% = functionattacks(1)
 testslowend% = functionattacks(manyattacks%-1) - functionattacks(manyattacks%-2)
  manyattacks5% = manyattacks4% : manyattacks4% = manyattacks3%
 manyattacks3% = manyattacks2% : manyattacks2% = manyattacks1%
 manyattacks1% = manyattacks%
 rate5=rate4 : rate4=rate3 : rate3=rate2 : rate2=rate1 : rate1=rate
  IF testquickend% =quickend% AND testslowend% = slowend% THEN
 result$ = "success"
  ENDIF
  :
 IF result$ = "noresult" THEN
 :
  IF testquickend% <= quickend% AND testslowend% >= slowend% THEN
 IF ratedir$ = "up" THEN increment = increment/2.1
 IF increment < 0.01 THEN increment = 0.01
 ratedir$ = "down"
 rate = rate-increment
 IF rate < 1.01 THEN rate = 1.01
  ENDIF
  :
  IF testquickend% >= quickend% AND testslowend% <= slowend% THEN
 IF ratedir$ = "down" THEN increment = increment/2.1
 IF increment < 0.01 THEN increment = 0.01
 ratedir$ = "up"
 rate = rate+increment
  ENDIF
  :
  IF testquickend% < quickend% AND testslowend% < slowend% THEN
 IF attacksdir$ = "up" THEN increment2% = increment2%/2
 IF increment2% < 1 THEN increment2% = 1
 attacksdir$ = "down"
 manyattacks% = manyattacks% - increment2%
 IF manyattacks% < 4 THEN manyattacks% = 4
  ENDIF
  :
  IF testquickend% > quickend% AND testslowend% > slowend% THEN
 IF attacksdir$ = "down" THEN increment2% = increment2%/2
 IF increment2% < 1 THEN increment2% = 1
 attacksdir$ = "up"
 manyattacks% = manyattacks% + increment2%
 IF manyattacks% < 4 THEN manyattacks% = 4
  ENDIF
  :
 ENDIF
 :
 IF manyattacks% = manyattacks2% AND manyattacks% = manyattacks4% AND manyattacks1% = manyattacks3% AND manyattacks1% = manyattacks5% AND manyattacks%<>manyattacks1% AND rate = rate1 AND rate = rate2 AND rate=rate3 AND rate=rate4 THEN
 doesitloop$ = "yes"
 ENDIF
 :
 IF(rate*10000)DIV1=(rate2*10000)DIV1AND(rate*10000)DIV1=(rate4*10000)DIV1 AND(rate1*10000)DIV1=(rate3*10000)DIV1AND(rate1*10000)DIV1=(rate5*10000)DIV1AND(rate*10000)DIV1<>(rate1*10000)DIV1THENmaybeloop$="yes"
 IF(rate*10000)DIV1=(rate3*10000)DIV1AND(rate1*10000)DIV1=(rate4*10000)DIV1AND(rate2*10000)DIV1=(rate5*10000)DIV1AND((rate*10000)DIV1<>(rate1*10000)DIV1OR(rate*10000)DIV1<>(rate2*10000)DIV1)THENmaybeloop$="yes" : REM 3-part loop
 IF maybeloop$="yes" AND manyattacks%=manyattacks1% AND manyattacks% = manyattacks2% AND manyattacks% = manyattacks3% AND manyattacks%=manyattacks4% AND manyattacks%=manyattacks5% THEN doesitloop$ = "yes"
 :
 IF doesitloop$ = "yes" THEN
 CLS
 IF quickend% >= testquickend1% THEN
  margin1 = (quickend%-testquickend1%)/quickend%*100
 ELSE
 margin1 = (testquickend1%-quickend%)/quickend%*100
 ENDIF
 IF slowend% >= testslowend1% THEN
  margin2 = (slowend%-testslowend1%)/slowend%*100
 ELSE
  margin2 = (testslowend1%-slowend%)/slowend%*100
 ENDIF
 IF quickend% >= testquickend% THEN
  margin3 = (quickend%-testquickend%)/quickend%*100
 ELSE
  margin3 = (testquickend%-quickend%)/quickend%*100
 ENDIF
 IF slowend%>=testslowend% THEN
  margin4 = (slowend%-testslowend%)/slowend%*100
 ELSE
  margin4 = (testslowend%-slowend%)/slowend%*100
 ENDIF
 IF ((margin1*10)DIV1)MOD10>4 THEN margin1% = margin1 ELSE margin1% = margin1
 IF ((margin2*10)DIV1)MOD10>4 THEN margin2% = margin2 ELSE margin2% = margin2
 IF ((margin3*10)DIV1)MOD10>4 THEN margin3% = margin3 ELSE margin3% = margin3
 IF ((margin4*10)DIV1)MOD10>4 THEN margin4% = margin4 ELSE margin4% = margin4
 VDU 7
  IF easiermenus$ = "n" THEN PROCwindow(10,69,90,48) ELSE PROCwindow(10,69,90,42)
   PRINT''" the search is looping between the two closest possible solutions, "
 PRINT " given the present bias (see below)"
 PRINT ' " do you want to opt for one of these, or carry on searching with"
 PRINT " a different bias (press A/B)"
   PRINT'" quickend ";testquickend1%;" (";margin1%;"% off ";quickend%;")"
   PRINT " slowend ";testslowend1%;" (";margin2%;"% off ";slowend%;")"
   PRINT " number of attacks ";manyattacks2%
 PRINT " rate ";rate2
 PRINT " bias ";bias
   PRINT'" quickend ";testquickend%;" (";margin3%;"% off ";quickend%;")"
   PRINT " slowend ";testslowend%;" (";margin4%;"% off ";slowend%;")"
   PRINT " number of attacks ";manyattacks1%
 PRINT " rate ";rate1
 PRINT " bias ";bias
 CASE GET$ OF
  WHEN "A","a" : numberoftries% = 3
  OTHERWISE
 ENDCASE
 numberoftries% +=1 : IF numberoftries% = 1 THEN bias=bias/2
 IF numberoftries% = 2 THEN bias =bias*4
 IF numberoftries% = 3 THEN
 PRINT'" three different biases now tried -"
 PRINT " to opt for one of the last three tries press A/B/C"
 PRINT " or to try again with fresh values press D"
 CASE GET$ OF
  WHEN "A","a" : bias = bias/2
  WHEN "B","b" : bias = bias/4
 WHEN "C","c" : result$ = "loop"
 WHEN "D","d" : PROCfunctionprelude
 ENDCASE
 ENDIF
 IF numberoftries% = 4 THEN result$ = "loop"
 IF result$ <> "loop" THEN
  manyattacks1% = 0 : manyattacks2% = 0 : manyattacks3% = 0 : manyattacks4% = 0 : manyattacks5% = 0
 rate1=0 : rate2=0 : rate3=0 : rate4=0 : rate5=0
 doesitloop$ = "" : maybeloop$ = ""
 ENDIF
 ENDIF
 ENDIF
 :
 UNTIL result$ <> "noresult"
 :
 CASE result$ OF
  WHEN "success" :
 PROCfunction
 IF easiermenus$ = "n" THEN PROCwindow(10,69,90,44) ELSE PROCwindow(10,69,90,42)
   PRINT''" quickend ";testquickend%
   PRINT' " slowend ";testslowend%
 PRINT "                  "
 PRINT'" rate ";rate
 PRINT'" bias ";bias
 PRINT'" number of attacks ";manyattacks%
 :
 IF seegraph$ = "y" THEN
 PRINT'" Do you want to see the graph? "
 CASE GET$ OF
  WHEN "Y","y" : PROCgraph
  OTHERWISE PROCfunctionpostlude
 ENDCASE
 ELSE PROCfunctionpostlude
 ENDIF
 :
  WHEN "loop" :
   PRINT'" - to opt for the first solution above press A, for the"
 PRINT   "   second press B, to try again with fresh values press F"
  CASE GET$ OF
   WHEN "A","a" : PROCfunction
   :
        IF seegraph$ = "y" THEN
          PRINT'" Do you want to see the graph? "
          CASE GET$ OF
           WHEN "Y","y" : PROCgraph
           OTHERWISE PROCfunctionpostlude
          ENDCASE
         ELSE PROCfunctionpostlude
        ENDIF
         :
   WHEN "B","b" : manyattacks%=manyattacks1% : rate = rate1
   PROCfunction
         IF seegraph$ = "y" THEN
          PRINT'" Do you want to see the graph? "
          CASE GET$ OF
           WHEN "Y","y" : PROCgraph
           OTHERWISE PROCfunctionpostlude
          ENDCASE
        ELSE PROCfunctionpostlude
       ENDIF
   WHEN "F","f" : PROCfunctionprelude
  ENDCASE
 ENDCASE
 :
 ENDPROC
 :
 REM**********************************************************
 :
 DEF PROCgraph
 :
 numplots% = 10000
 segment = numplots%/(manyattacks%-1)
 horizline = numplots% - segment
 count =1
 REM convolutions below necc simply to get a 'square' graph
 factor1 = numplots%/rate
 factor2 = rate/(rate-1)
 factor3 = rate/numplots%
 factor4 = numplots%/((FNfunction(1)*factor1)-(FNfunction(rate)*factor1))
 factor5 = FNfunction(rate)*factor1
 factor6 = (factor4*factor5)-factor5
 MODE 31 : CLG : CLS
 PRINT TAB(50) " rate              ";rate
 PRINT TAB(50) " bias              ";bias
 PRINT TAB(50) " number of attacks ";manyattacks%
 PRINT TAB(50) " quickend ";functionattacks(1)
 PRINT TAB(50) " slowend ";functionattacks(manyattacks%-1)-functionattacks(manyattacks%-2)
 PRINT TAB(50) " total duration ";totaldur%
 MOVE 1000,0 : DRAW 0,0 : DRAW 0,1000
 scaling = 900/numplots%
 FOR x = 1 TO rate STEP factor3
 xaxis = ((x*factor1)-factor1)*2
 yaxis = ((FNfunction(x)*factor1)*factor4)-(factor5 + factor6)
 xplot = xaxis*scaling : yplot = yaxis*scaling
 DRAW xplot,yplot
 REM the function uses x = 1 to rate, but the graph plots (xaxis & yaxis) run from 0 to 1000 in each axis
 IF yaxis <= horizline THEN
  LINE 0,yplot, xplot,yplot
  LINE xplot,yplot, xplot,0
 MOVE xplot,yplot
  count += 1
  horizline -= segment
 ENDIF
 NEXT
 PROCfunctionpostlude
 ENDPROC
 :
 REM***************************************
 :
 DEF PROCfunctionpostlude
 :
 IF rate <> 1 THEN
 PRINT '" Accel or rit"
 PRINT " (press A/R or 1/2)"
 CASE GET$ OF
  WHEN "A","a","1" :
   FOR count% = 0 TO (manyattacks%-1)
    attacks1%(count%) = totaldur% - (functionattacks((manyattacks%-1)-count%))
   NEXT
  direction$ = "accel"
 :
  OTHERWISE
 FOR count = 0 TO (manyattacks%-1)
  attacks1%(count) = functionattacks(count)
 NEXT
  direction$ = "rit"
 ENDCASE
 ELSE
 FOR count% = 0 TO (manyattacks%-1)
  attacks1%(count%) = functionattacks(count%)
 NEXT
  direction$ = "rit"
 ENDIF
 :
 method$ = "raw"
 IF funcinput$ = "points" OR funcinput$ = "displayed" THEN quiz$ = "no"
 COLOUR 0 : COLOUR 191 : CLS : PROCinsertattacks
 ENDPROC
 :
 REM***************************************
 :
 DEF FNfunction(x)
 = (rate/x)-(x/bias)+(rate/bias)
 :
 REM***************************************
 :
 DEF PROCprerhythmicize
 :
 PROCwindow(20,71,90,38)
 CLS : PRINT' " Do you want to re-define the criteria for irrational groups, "
 PRINT     '  " keep them or use CAC's defaults (Y/K/D) "
 PRINT''"  (criteria are: "
 PRINT' "   GROUP LENGTHS ";shortirrat%;" beats - "; longirrat%;" beats "
 PRINT' "   GROUP LOCATIONS any 1/";irratbeats%;" of a bar "
 PRINT' "   FALLBACK LOCATIONS any 1/";irratbeats1%;" of a bar "
 PRINT' "   SHORTEST DURATION ";mindur%;" beats "
 PRINT' "   COMPLEXITY ";given%
 PRINT' "   DEFAULT DIVISIONS 1/";defaultsieve;" of a bar) "
  CASE GET$ OF
  WHEN "Y","y" :
 PRINT''"   Give GROUP LENGTH of the SHORTEST irrational group desired... "
 INPUT' "     bars "bars%
 INPUT'"     beats "beats%
 PROCalterbeats
 shortirrat% = (bars%*960)+beats%
 PRINT'"   Give GROUP LENGTH of the LONGEST irrational group desired... "
 INPUT'"     bars "bars%
 INPUT'"     beats "beats%
 PROCalterbeats
 longirrat% = (bars%*960)+beats%
 IF longirrat%/beatfactor% > 999 THEN
 VDU 7 : PRINT'" !!Maximum length for irrational groups is 999 beats!! "
 PRINT'" (to try again press C) "
 CASE GET$ OF
  WHEN"C","c" : CLS :PROCprerhythmicize
 ENDCASE
 ENDIF
 :
 CLS
 PRINT''"  (criteria are now: "
 PRINT' "   GROUP LENGTHS ";shortirrat%;" beats - "; longirrat%;" beats "
 PRINT' "   GROUP LOCATIONS any 1/";irratbeats%;" of a bar "
 PRINT' "   FALLBACK LOCATIONS any 1/";irratbeats1%;" of a bar "
 PRINT' "   SHORTEST DURATION ";mindur%;" beats "
 PRINT' "   COMPLEXITY ";given%
 PRINT' "   DEFAULT DIVISIONS 1/";defaultsieve;" of a bar) "
 :
 PRINT''"    For GROUP LOCATION which beats of the bar is it acceptable to "
 PRINT '"    begin irrational groups of attacks on (1 = first beat of bar only, "
 PRINT '"    2 = any 1/2 bar, 3 = any 1/3 bar etc) "
 INPUT '"    (use this to control allowability of certain group lengths) "irratbeats%
 REM 1-16 make integers except 7,9,11,13 & 14
 PRINT''"    And for FALLBACK LOCATIONS which beats of the bar is it acceptable "
 PRINT' "    to begin 'fall back' groups, ie ones beginning or ending with "
 INPUT '"    rests, on (1, 2, 3 etc - also for controlling lengths allowable) "irratbeats1%
 PROCwindow(20,71,90,35)
 CLS
  PRINT''"  (criteria are now: "
 PRINT' "   GROUP LENGTHS ";shortirrat%;" beats - "; longirrat%;" beats "
 PRINT' "   GROUP LOCATIONS any 1/";irratbeats%;" of a bar "
 PRINT' "   FALLBACK LOCATIONS any 1/";irratbeats1%;" of a bar "
 PRINT' "   SHORTEST DURATION ";mindur%;" beats "
 PRINT' "   COMPLEXITY ";given%
 PRINT' "   DEFAULT DIVISIONS 1/";defaultsieve;" of a bar) "
 :
 PRINT''"    What is the SHORTEST ALLOWABLE DURATION, in beats "
 INPUT' "    (any less than this will be 'edited up') "mindur%
 PROCalterbeats
 sieve = 960/mindur%
 buffer% = 960/(sieve*2)
 PRINT''"    What is the maximum allowable irrational COMPLEXITY, "
 PRINT '"    eg, '5' allows upto 5 'in the time of' (this parameter "
INPUT  '"    controls the trade-off between user-friendliness and accuracy) "given%
:
CLS
 PRINT''"  (criteria are now: "
 PRINT' "   GROUP LENGTHS ";shortirrat%;" beats - "; longirrat%;" beats "
 PRINT' "   GROUP LOCATIONS any 1/";irratbeats%;" of a bar "
 PRINT' "   FALLBACK LOCATIONS any 1/";irratbeats1%;" of a bar "
 PRINT' "   SHORTEST DURATION ";mindur%;" beats "
 PRINT' "   COMPLEXITY ";given%
 PRINT' "   DEFAULT DIVISIONS 1/";defaultsieve;" of a bar) "
 :
 PRINT''"    According to DEFAULT DIVISIONS, irrationals will avoid small  "
 PRINT '"    divisions beyond a certain point, unless required by the rhythm. "
 PRINT '"    Confirm or re-set this default, which is currently at ";defaultsieve;" divisions "
 INPUT '"    of the bar (same trade-off as above) "defaultsieve
 WHEN "D","d" :
  PROCrhythmdefaults
  OTHERWISE
 ENDCASE
 :
 PROCquantize
 :
 attacks5%() = attacks2%()
 attacks3%() = attacks3%()/(10^3) : REM list of actual bar nos
 FOR count% = 0 TO (manyattacks%-1)
  attacks4%(count%) = attacks2%(count%) MOD (10^3)
 NEXT : REM list of actual beat nos (attacks2 containing bar/beat nos remains intact)
 :
 REM routine to fill array nodes%() with acceptable beats of bar to start irrat groups on
 IF irratbeats% > 0 THEN
  nextbeat% = 960/irratbeats%
  FOR count% = 1 TO (irratbeats%-1)
   nodes%(count%) = nodes%(count%-1) + nextbeat%
  NEXT
 ENDIF
 :
 REM routine to fill nodes1%() with acceptable beats to start fallback groups on
 nextbeat% = 960/irratbeats1%
 FOR count% = 1 TO (irratbeats1% - 1)
  nodes1%(count%) = nodes1%(count%-1) + nextbeat%
 NEXT
 nodes1%(irratbeats1%) = 960
 :
 REM routine to test whether first attack is on an acceptable beat
 firstattack$ = "offbeat"
 count% = 0
 REPEAT
  IF attacks4%(0) = nodes%(count%) THEN firstattack$ = "onbeat"
  count% += 1
 UNTIL firstattack$ = "onbeat" OR count% > (irratbeats%-1)
 :
 IF firstattack$ = "onbeat" THEN
  endbeat% = attacks2%(0)
  endcell% = 0
  status$ = "onbeat"
 firstgroup$ = "y"
 ELSE
 word$ = ""
  count% = irratbeats1%
  REPEAT
   IF nodes1%(count%) < attacks4%(0) THEN
    endbeat% = (attacks3%(0)*(10^3)) + nodes1%(count%)
 word$ = "found"
   ENDIF
   count% -= 1
  UNTIL word$ = "found" OR count% < 0
  endcell% = 0
  status$ = ""
 firstgroup$ = "y"
 ENDIF
 PROCrhythmicize
 :
 ENDPROC
 :
 REM***************************************************************
 :
 DEF PROCfunction
 :
 IF rate = 1 THEN
 :
 unit = totaldur%/(manyattacks%-1)
 :
 FOR count% = 1 TO (manyattacks%-2)
 :
  attackpoint = unit * count%
  :
  REM rounding-off to nearest integer
  attackpoint = attackpoint * 10
  attackpoint = attackpoint DIV 1
  fraction = attackpoint MOD 10
  IF fraction > 4 THEN
  attackpoint = (attackpoint DIV 10) + 1
  ELSE
  attackpoint = attackpoint DIV 10
  ENDIF
  functionattacks(count%) = attackpoint
  REM list of 'real' attack-values 0-totaldur% rounded to nearest integer
  :
 NEXT
 :
 functionattacks(manyattacks%-1) = totaldur%
 :
 ELSE
 :
 yrange = FNfunction(1) - 1
 segment = yrange/(manyattacks%-1)
 ypoint = FNfunction(1)
 :
 FOR count% = 1 TO (manyattacks%-2)
 :
  ypoint -= segment
  xincrement = rate - 1
  xtry = 1 + (xincrement/2)
  :
 tolerance = yrange/100000 : REM this ought to give highly accurate results
 :
 IF result$ = "success" OR result$ = "loop" OR count% = 1 OR count% = (manyattacks%-2) THEN
 :
 WHILE FNfunction(xtry) > (ypoint+tolerance) OR FNfunction(xtry) < (ypoint-tolerance)
  :
   xincrement = xincrement/2
   IF FNfunction(xtry) < ypoint THEN
    xtry -= xincrement
   ELSE
    xtry += xincrement
   ENDIF
  :
  ENDWHILE
 :
 ENDIF
 :
  functionattacks(count%) = xtry
  :
 NEXT
 :
 functionattacks(0) = 1
 functionattacks(manyattacks%-1) = rate
 :
 REM scaling & rounding routine
 functionattacks() -= 1
 divider = rate-1
 FOR count% = 0 TO (manyattacks%-1)
  functionattacks(count%) = functionattacks(count%)/divider*totaldur%
 NEXT
 :
 FOR count% = 1 TO (manyattacks%-1)
  number = functionattacks(count%)
  number = number*10
  number = number DIV 1
  fraction = number MOD 10
  IF fraction > 4 THEN
   number = (number DIV 10) + 1
  ELSE
   number = number DIV 10
  ENDIF
  functionattacks(count%) = number
  REM list of 'real' attack-values 0-totaldur% rounded to nearest integer
 NEXT
 :
 ENDIF
 :
 ENDPROC
 :
 REM**************************************************************
 :
 DEF PROCrhythmicize
 :
 cant% = 0 : REM for notategroup%() subscript - poss change later
 notategroup%() = 0
 :
 REPEAT
 :
 status1$ = status$
 status$ = ""
 startbeat% = endbeat%
 :
 IF status1$ = "onbeat" OR firstgroup$ = "y" THEN
  startcell% = endcell%
 ELSE startcell% = endcell% + 1
 ENDIF
 firstgroup$ = "n"
 :
 cell% = startcell%
 count% = 0
 condition$ = "full"
 :
 PROCbuffers
 :
 WHILE status$ = "" AND attacks5%(cell%) <= rightbuffer% AND cell% < manyattacks%
 :
  IF attacks5%(cell%) >= leftbuffer% AND attacks5%(cell%) <= rightbuffer% THEN
  :
  IF attacks4%(cell%) >= (960-buffer%) THEN attacks4%(cell%) = (960-attacks4%(cell%))*-1 : REM catches attacks just before barline
  :
   REPEAT
   :
    IF attacks4%(cell%) >= (nodes%(count%)-(buffer%)) AND attacks4%(cell%) <= (nodes%(count%)+(buffer%)) THEN
    :
  IF attacks4%(cell%) < 0 THEN
   br% = attacks3%(cell%)+1
   attacks4%(cell%) = 960 - (attacks4%(cell%)*-1)
   beforebar$ = "y"
  ELSE
   br% = attacks3%(cell%)
   beforebar$ = "n"
  ENDIF
  :
  IF attacks5%(cell%) >= ((br%*10^3)+nodes%(count%)) THEN
   diff% = attacks4%(cell%) - nodes%(count%) + ((attacks3%(cell%)-br%)*960)
  ELSE
   diff% = nodes%(count%) - attacks4%(cell%) + ((br%-attacks3%(cell%))*960)
  ENDIF
  :
  IF attacks5%(cell%+1) >= ((br%*10^3)+nodes%(count%)) THEN
   diff1% = attacks4%(cell%+1)-nodes%(count%)+((attacks3%(cell%+1)-br%)*960)
  ELSE
   diff1% = nodes%(count%)-attacks4%(cell%+1)+((br%-attacks3%(cell%+1))*960)
  ENDIF
  :
 IF diff% <= diff1% THEN
 :
     status$ = "onbeat"
     IF beforebar$ = "y" THEN
      attacks5%(cell%) = (attacks3%(cell%)*10^3) + 1000 + nodes%(count%)
     ELSE
      attacks5%(cell%) = (attacks3%(cell%)*10^3) + nodes%(count%)
     ENDIF
     endbeat% = attacks5%(cell%)
     endcell% = cell%
 difference% = endcell% - startcell%
 IF status1$ = "onbeat" AND difference% = 1 THEN condition$ = "empty"
 IF status1$ = "" AND difference% = 0 THEN condition$ = "empty"
    :
 ENDIF
 :
    ENDIF
    :
    count% += 1
    :
   UNTIL count% = irratbeats% OR status$ = "onbeat"
   :
  ENDIF
  :
  cell% += 1
  count% = 0
  :
 ENDWHILE
 :
 :
 IF status$ = "" THEN
  word$ = ""
  leftbuffer% = leftbuffer% + buffer%
  :
  REPEAT
  :
  IF nodes1%(count%) >= (leftbuffer%MOD10^3) THEN
  :
   IF nodes1%(count%) = 960 THEN
    endbeat% = ((leftbuffer%DIV(10^3))*10^3)+(10^3)
   ELSE
    endbeat% = ((leftbuffer%DIV(10^3))*(10^3)) + nodes1%(count%)
   ENDIF
 :
 IF status1$ = "" AND attacks5%(startcell%) > endbeat% THEN
  condition$ = "empty"
 ENDIF
 IF status1$ = "onbeat" AND attacks5%(startcell%+1) > endbeat% THEN
  condition$ = "empty"
 ENDIF
 :
 IF condition$ = "full" THEN
   :
   searchcell% = startcell% - 1
   REPEAT
    searchcell% += 1
   UNTIL attacks5%(searchcell%) > endbeat% OR searchcell% = manyattacks%
   :
   endcell% = searchcell% - 1
 ENDIF
   word$ = "done"
   :
  ENDIF
  :
  count% += 1
  :
  UNTIL word$ = "done"
  :
  :
 ENDIF
 :
 PROCprechoosegroup
 :
 UNTIL endbeat% >= attacks5%(manyattacks%-1)
 :
 IF seeinfo$ = "y" THEN
 CLS
 durat% = 0
 counter% = 0
 thing$ = "on"
 PROCwindow(10,60,90,5) : CLS
 VDU 14
 PRINT '" The group of rhythmicised attacks will be at "
 PRINT"  "
 PRINT TAB(28) "ATTACKS AT";
 PRINT TAB(46) "DURATIONS";
 PRINT TAB(64) "RATIOS"
 attacks5%(manyattacks%) = 10^9
 FOR count% = 0 TO manyattacks%
 IF counter% < cant% THEN
 item% = ((notategroup%(counter%,1)DIV10^4)*10^3)+(notategroup%(counter%,0)MOD10^3)
  IF item% = attacks5%(count%) THEN
   PRINT TAB(15) item%;
  counter% += 1
 thing$ = "on"
  ENDIF
 ENDIF
 IF counter% < cant% THEN
 item% = ((notategroup%(counter%,1)DIV10^4)*10^3)+(notategroup%(counter%,0)MOD10^3)
  IF item% < attacks5%(count%) THEN
   PRINT TAB(15) item%
 counter% += 1
 thing$ = "on"
 ENDIF
 ENDIF
 IF counter% < cant% THEN
 IF thing$ = "on" THEN
 IF (notategroup%(counter%,0)DIV1000)= attacks5%(count%) THEN
 PRINT "  "
 PRINT " "
 PRINT TAB(0) (notategroup%(counter%,1)MOD10000);
  PRINT TAB(15) (notategroup%(counter%,0)DIV1000);
 thing$ = "off"
 ENDIF
 :
 IF (notategroup%(counter%,0)DIV1000)< attacks5%(count%) THEN
 PRINT "  "
 PRINT " "
 PRINT TAB(0) ((notategroup%(counter%,1))MOD10000);
 PRINT TAB(15) (notategroup%(counter%,0)DIV1000)
 thing$ = "off"
 ENDIF
 ENDIF
 ENDIF
 :
 IF thing$ = "on" THEN PRINT'"  "
 :
 IF count% < manyattacks% THEN
  PRINT TAB(25)attacks5%(count%);
 IF count% < (manyattacks%-1) THEN
  durat1% = durat%
  durat% = (attacks5%(count%+1)MOD10^3)-(attacks5%(count%)MOD10^3)
  addon% = ((attacks5%(count%+1)DIV(10^3))-(attacks5%(count%)DIV(10^3)))*960
 durat% = durat% + addon%
  PRINT TAB(42) durat%;
  IF count%>0 THEN
 IF direction$ = "rit" THEN ratio = durat%/durat1% ELSE ratio = durat1%/durat%
 CASE ratio OF
  WHEN 0.5 : PRINT TAB(65) "0.5"
  WHEN 1.0 : PRINT TAB(65) "1.0"
  WHEN 1.5 : PRINT TAB(65) "1.5"
  WHEN 2.0 : PRINT TAB(65) "2.0"
  WHEN 2.5 : PRINT TAB(65) "2.5"
  OTHERWISE PRINT TAB(65) ratio
 ENDCASE
  ENDIF
 ENDIF
 ENDIF
 NEXT
 :
 VDU 15
ENDIF
 :
 CLS
 :
 ENDPROC
 :
 REM*******************************************
 :
 DEF PROCbuffers
 :
 beatnum% = (startbeat%MOD(10^3)) + shortirrat% - buffer%
 carrybars% = beatnum% DIV 960
 beatnum% = beatnum% - (carrybars%*960)
 leftbuffer% = ((startbeat%DIV(10^3))*10^3) + (carrybars%*(10^3)) + beatnum%
 :
 beatnum% = (startbeat%MOD(10^3)) + longirrat% + buffer%
 carrybars% = beatnum% DIV 960
 beatnum% = beatnum% - (carrybars%*960)
 rightbuffer% = ((startbeat%DIV(10^3))*10^3) + (carrybars%*(10^3)) + beatnum%
 :
 REM tolerance of 'buffer%' incorporated into buffers
 :
 ENDPROC
 :
 REM********************************************8
 :
 DEF PROCprechoosegroup
 :
 :
 IF condition$ = "full" THEN
 :
  REM routine to find grouplength%
  carrybars% = (endbeat% DIV (10^3)) - (startbeat% DIV (10^3))
  grouplength% = (endbeat% MOD (10^3)) - (startbeat% MOD (10^3)) + (carrybars% * 960)
  :
  REM routine to find first and last  durats
  IF status1$ = "onbeat" THEN
  :
   carrybars% = attacks3%(startcell%+1)-attacks3%(startcell%)
   firstdur% = attacks4%(startcell%+1)-attacks4%(startcell%)+(carrybars%*960)
  ELSE
   carrybars% = attacks3%(startcell%)-(startbeat%DIV(10^3))
   firstdur% = attacks4%(startcell%)-(startbeat%MOD(10^3))+(carrybars%*960)
  ENDIF
  :
  IF status$ = "onbeat" THEN
  :
   carrybars% = attacks3%(endcell%)-attacks3%(endcell%-1)
   lastdur% = attacks4%(endcell%)-attacks4%(endcell%-1)+(carrybars%*960)
  ELSE
   carrybars% = (endbeat%DIV(10^3))-attacks3%(endcell%)
   lastdur% = (endbeat%MOD(10^3))-attacks4%(endcell%)+(carrybars%*960)
  ENDIF
  :
  :
  :
  REM routine to determine each individual duration
  IF status1$ = "onbeat" AND status$ = "onbeat" THEN
   numdurs% = endcell% - startcell%
   FOR count% = 2 TO (numdurs%-1)
    dur%(count%) = attacks1%(startcell%+count%)-attacks1%(startcell%+(count%-1))
   NEXT
   dur%(1) = firstdur%
   dur%(numdurs%) = lastdur%
  ENDIF
  :
  IF status1$ = "onbeat" AND status$ = "" THEN
   numdurs% = endcell% - startcell% + 1
   FOR count% = 2 TO (numdurs%-1)
    dur%(count%) = attacks1%(startcell%+count%)-attacks1%(startcell%+(count%-1))
   NEXT
   dur%(1) = firstdur%
   dur%(numdurs%) = lastdur%
  ENDIF
  :
  IF status1$ = "" AND status$ = "onbeat" THEN
   numdurs% = endcell% - startcell% + 1
   FOR count% = 2 TO (numdurs%-1)
    dur%(count%) = attacks1%(startcell%+(count%-1))-attacks1%(startcell%+(count%-2))
   NEXT
   dur%(1) = firstdur%
   dur%(numdurs%) = lastdur%
  ENDIF
  :
  IF status1$ = "" AND status$ = "" THEN
   numdurs% = endcell% - startcell% + 2
   FOR count% = 2 TO (numdurs%-1)
    dur%(count%) = attacks1%(startcell%+(count%-1))-attacks1%(startcell%+(count%-2))
   NEXT
   dur%(1) = firstdur%
   dur%(numdurs%) = lastdur%
  ENDIF
 :
 REM routine to find enddur (ie smallest duration)
 enddur = 10^9
 FOR count% = 1 TO numdurs%
  IF dur%(count%) < enddur THEN
   enddur = dur%(count%) : enddurnum% = count%
  ENDIF
 NEXT
 :
 REM routine to find numsubdivs of enddur poss, using a default min division, forcing that
 REM down with durats less than it, but not beyond the minimum div given by sieve
 defaultmindur% = 960/defaultsieve
 IF enddur < defaultmindur% THEN
  x = 960/enddur : defaultmindur% = 960/x
 ELSE x = defaultsieve
 ENDIF
 IF x > sieve THEN
  x = sieve : defaultmindur% = mindur%
 ENDIF
  numsubdivs = x * enddur / 960 * 1.04 : REM 1.04 catches numbers just below whole nos eg 1.96
 IF numsubdivs < 1 THEN numsubdivs% = 1 ELSE numsubdivs% = numsubdivs
  :
REM repeat/until loop to keep increasing and decreasing enddur until a 'reasonable' proportiontotal% is found
 switch$ = "A" : nudge% = -5
REPEAT
 nudge% += 5
 IF switch$ = "A" THEN enddur += (nudge%/100) ELSE enddur -= (nudge%/100)
 IF enddur < 1 THEN
VDU 7 : PRINT''" !!!THE COMPLEXITY LEVEL IS TOO LOW "
PRINT" FOR LONG GROUPS CONSISTING "
PRINT" OF ODD NUMBERS OF BEATS, "
PRINT" eg 13 QUAVERS, 31 SEMIS ETC.  "
PRINT" INCREASE THIS LEVEL OR SHORTEN "
PRINT" GROUPS OR, BEST, REDUCE INPUTS 3/4!!! "
PRINT" (press C to continue) "
CASE GET$ OF
 WHEN"C","c" : PROCdisplay
ENDCASE
ENDIF
 :
 IF switch$ = "A" THEN switch$ = "B" ELSE switch$ = "A"
 numsubdivs1 = x*enddur/960*1.04
 IF numsubdivs1 < 1 THEN numsubdivs% = 1 ELSE numsubdivs% = numsubdivs1
REM prev 2 lines allow 'stretched' enddurs to include more (or less) subdivs
REM without altering original subdivs, which tends to vitiate the whole process
 :
  REM routine to create list of attacks 0 - totalduration
  FOR count% = 1 TO numdurs%
   groupattacks%(count%) = groupattacks%(count%-1)+dur%(count%)
  NEXT
  REM groupattacks%(numdurs%) SHOULD = grouplength%
  :
  timeround% = 1
  PROCchoosegroup
  :
  REM routine to place error-values in order
  errororder%() = 10000000
  FOR count% = 1 TO numsubdivs%
  tick% = 0
  REPEAT
do$ = "n"
  tick%+=1 : inplace$ = "n"
   IF error%(count%) < errororder%(tick%) THEN
    FOR tock% = numsubdivs% TO tick% STEP -1
     errororder%(tock%+1) = errororder%(tock%)
     errororder1%(tock%+1) = errororder1%(tock%)
    NEXT
    errororder%(tick%) = error%(count%) : errororder1%(tick%) = count% : inplace$ = "y"
   ENDIF
 UNTIL inplace$ = "y"
  NEXT
  :
  timeround% = 2 : tog% = 0
 REPEAT
  tog%+=1 : closest% = errororder1%(tog%)
  PROCchoosegroup
 PROCcheckproportiontotal
 UNTIL proportiontotal$ = "OK" OR tog% = numsubdivs%
 UNTIL proportiontotal$ = "OK"
  REM routine to alter attacks5%() to closest group & to save notation in a parallel temp array
  IF status1$ = "onbeat" THEN
   FOR count% = 1 TO (numdurs%-1)
    totalbeat% = (startbeat%MOD(10^3))+rhythmicattacks%(count%)
    carrybars% = ((totalbeat%/960)DIV1)
    beat% = totalbeat%-(carrybars%*960)
    bar% = (carrybars%+(startbeat%DIV(10^3)))*(10^3)
    attacks5%(startcell%+count%) = beat% + bar%
   NEXT
  ENDIF
  :
  IF status1$ = "" THEN
   FOR count% = 1 TO (numdurs%-1)
    totalbeat% = (startbeat%MOD(10^3))+rhythmicattacks%(count%)
    carrybars% = ((totalbeat%/960)DIV1)
    beat% = totalbeat% - (carrybars%*960)
    bar% = (carrybars% + (startbeat%DIV(10^3))) * (10^3)
    attacks5%(startcell%+(count%-1)) = beat% + bar%
   NEXT
  ENDIF
  :
  notategroup%(cant%,0) = (startbeat%*10^3)+(endbeat%MOD10^3)
  notategroup%(cant%,1) = ((endbeat%DIV10^3)*10^4)+proportiontotal%
  cant% += 1
  :
 ENDIF
 :
 ENDPROC
 :
 REM******************************************************
 :
 DEF PROCchoosegroup
 :
 IF timeround% = 1 THEN
  start% = 1 : finish% = numsubdivs%
 ELSE start% = closest% : finish% = closest%
 ENDIF
 :
 error%() = 0
 FOR count% = start% TO finish%
 :
  FOR count1% = 1 TO numdurs%
  IF count1% = enddurnum% THEN thedur% = enddur ELSE thedur% = dur%(count1%)
 IF numsubdivs < 1 THEN
  proportion = thedur%/enddur*numsubdivs/1.04
 ELSE proportion = thedur%/enddur*count%
 ENDIF
   IF (((proportion*10)DIV1)MOD10) < 5 THEN
    proportion%(count1%) = (proportion) DIV 1
   ELSE proportion%(count1%) = ((proportion) DIV 1) + 1
   ENDIF
 IF proportion%(count1%) < 1 THEN proportion%(count1%) = 1
  NEXT
  :
  proportiontotal% = 0
  :
  FOR count2% = 1 TO numdurs%
   proportiontotal% = proportiontotal%+proportion%(count2%)
  NEXT
  :
  unit = grouplength%/proportiontotal%
  :
 rhythmicattack = 0
  FOR count3% = 1 TO numdurs%
 rhythmicattack = rhythmicattack + (proportion%(count3%)*unit)
 IF (((rhythmicattack*10)DIV1)MOD10) < 5 THEN
  rhythmicattacks%(count3%) = rhythmicattack DIV 1
 ELSE
  rhythmicattacks%(count3%) = ((rhythmicattack)DIV1)+1
 ENDIF
  NEXT : REM rhythmicattacks%(numdurs%) SHOULD = grouplength%
  :
  REM compare attackpoints with attackpoints
  FOR count4% = 1 TO (numdurs%-1)
   IF rhythmicattacks%(count4%) <= groupattacks%(count4%) THEN
    error%(count%) = error%(count%) + (groupattacks%(count4%) - rhythmicattacks%(count4%))
   ELSE
    error%(count%) = error%(count%)+(rhythmicattacks%(count4%)-groupattacks%(count4%))
   ENDIF
  NEXT
  :
 NEXT
 :
 ENDPROC
 :
 REM***************************************************************
 :
 DEF PROCseriesattacks
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,69,70,55) ELSE PROCwindow(20,69,70,42)
 PRINT '" Raw beat numbers      R "
 PRINT '" Already rhythmicized  A "
 PRINT '" Multiplied by factors F "
 PRINT '" Played                P "
 PRINT '" Single attack         1 "
 :
 CASE GET$ OF
 REM CASE 1
  WHEN "A","a" :
   count% = 0 : cant% = 0 :
   notategroup%() = 0 : finished$ = "n"
   :
   REPEAT
   :
    CLS
    PRINT '" single attack                            S "
    PRINT '" group of attacks (including all tuplets) G "
    PRINT '" finished                                 F "
    CASE GET$ OF
    REM CASE 2
     WHEN "S","s","1","0" :
     :
      CLS
      INPUT' " bar"bar%
      INPUT' " beat"beats%
      PROCalterbeats
      attacks2%(count%) = (bar%*(10^3)) + beats%
      count% += 1
     :
     WHEN "G","g" :
      CLS
      INPUT' " starting at bar "bars%
      INPUT' "             beat "beats%
      PROCalterbeats
      start% = (bars%*(10^3))+beats%
      INPUT' " ending at bar "bars%
      INPUT' "           beat "beats%
      PROCalterbeats
      end% = (bars%*(10^3))+beats%
      INPUT '" number of divisions "numdivs%
      notategroup%(cant%,0) = (start%*10^3)+(end%MOD10^3)
      notategroup%(cant%,1) = ((end%DIV10^3)*10^4)+numdivs%
      cant% += 1
 beat% = (start%)MOD(10^3) : bar% = (start%)DIV(10^3)
      :
      grouplength% = ((end%MOD(10^3))-(start%MOD(10^3)))+(((end%DIV(10^3))-(start%DIV(10^3)))*960)
      unit = grouplength%/numdivs%
      :
      IF (grouplength%/beatfactor%) > 999 THEN
       PRINT'''" !!!Maximum group length is 999 macro-beats!!! "
       PRINT" (press C to try again) "
       CASE GET$ OF
       REM CASE 3
        WHEN "C","c": CLS : PROCseriesattacks
        OTHERWISE PROCdisplay
       ENDCASE
       REM ENDCASE 3
      ENDIF
      IF numdivs% > 9999 THEN
       PRINT'''" !!!Maximum number of divisions is 9999!!! "
       PRINT" (press C to try again) "
       CASE GET$ OF
       REM CASE 4
        WHEN "C","c": CLS : PROCseriesattacks
        OTHERWISE PROCdisplay
       ENDCASE
       REM ENDCASE 4
      ENDIF
      :
      INPUT '" how many attacks "numattacks%
      CLS
      FOR counter% = 1 TO numattacks%
       PRINT '" attack ";counter%;" is on "
       INPUT  " division number "div%
       place = ((div%-1)*unit)
       IF (((place*10)DIV1)MOD10) < 5 THEN
        place% = (place)DIV1
       ELSE place% = ((place)DIV1)+1
       ENDIF
       :
       beatnum% = beat% + place%
       carrybars% = (beatnum%/960)DIV1
       beatnum% = beatnum% - (carrybars%*960)
       barnum% = carrybars% + bar%
       attacks2%(count%) = (barnum%*(10^3)) + beatnum%
       count% += 1
      NEXT
     :
     WHEN "F","f" : finished$ = "y"
     ENDCASE
     REM ENDCASE 2
    :
    UNTIL finished$ = "y"
    :
    method$ = "alreadyrhythmicized" : manyattacks% = count%
    attacks5%() = attacks2%() : rhythmicized$ = "y"
   :


WHEN "R","r","0" :
REM function will feed a sim string of beat values 0 - n into attacks1%()
 :
 attacks1%() = 0
 CLS
 INPUT' " How many attacks "manyattacks%
 :
 IF manyattacks% > 2 THEN
 PRINT'" Are the intervals between them the same? "
 CASE GET$ OF
  WHEN "N","n","2" : sameintervals$ = "n"
  OTHERWISE sameintervals$ = "y"
 ENDCASE
 ELSE sameintervals$ = "y"
 ENDIF
 :
IF manyattacks% > 1 THEN
:
CASE sameintervals$ OF
 WHEN "n" :
FOR count% = 1 TO (manyattacks% - 1)
  PRINT' " Give the interval between attacks ";count%;" and ";count%+1;"... "
  INPUT'"   bars "bars%
  INPUT'"   beats "beats%
   PROCalterbeats
  onbeat% = (bars%*960)+beats%
  attacks1%(count%) = attacks1%(count%-1) + onbeat%
 NEXT
 WHEN "y" :
  PRINT'" The intervaly between them is "
  INPUT'"   bars "bars%
  INPUT'"   bears "beats%
  PROCalterbeats
  onbeat% = (bars%*960)+beats%
  FOR count% = 1 TO (manyattacks%-1)
   attacks1%(count%) = attacks1%(count%-1) + onbeat%
  NEXT
:
ENDCASE
:
ENDIF
 method$ = "raw" : attacks1%(0) = 0


WHEN "1" :
REM function will feed a sim string of beat values 0 - n into attacks1%()
 :
 manyattacks% = 1
 :
 method$ = "raw" : attacks1%(0) = 0
:
 WHEN "F","f" :
REM function will feed a sim string of beat values 0 - n into attacks1%()
 :
 attacks1%() = 0
 INPUT' " How many attacks "manyattacks%
 :
 FOR count% = 1 TO (manyattacks% - 1)
  IF count% = 1 THEN
   PRINT' " Give the interval between attacks ";count%;" and ";count%+1;"... "
   INPUT'"   bars "bars%
   INPUT "   beats "beats%
   PROCalterbeats
   onbeat% = (bars%*960)+beats%
   attacks1%(count%) = attacks1%(count%-1) + onbeat%
  ELSE
   PRINT' " Multiply by ? to give the interval between attacks ";count%;" and ";count%+1;"... "
    IF count% = 2 THEN onbeat% = attacks1%(count%-1)
    CASE GET$ OF
     WHEN "0": onbeat% = onbeat% * 1.03
     WHEN "1": onbeat% = onbeat% * 1.04
     WHEN "2": onbeat% = onbeat% * 1.06
     WHEN "3": onbeat% = onbeat% * 1.09
     WHEN "4": onbeat% = onbeat% * 1.13
     WHEN "5": onbeat% = onbeat% * 1.19
     WHEN "6": onbeat% = onbeat% * 1.29
     WHEN "7": onbeat% = onbeat% * 1.41
     WHEN "8": onbeat% = onbeat% * 1.61
     WHEN "9": onbeat% = onbeat% * 1.91
    ENDCASE
   attacks1%(count%) = attacks1%(count%-1) + onbeat%
  ENDIF
 NEXT
 method$ = "raw" : attacks1%(0) = 0
 :
 WHEN "P","p" :
  CLS
  PRINT " Play the rhythm using any"
  PRINT " keys or the spacebar"
  PRINT'" When finished, press ~"
  :
  key$ = GET$ : TIME = 0 : VDU 7 : manyattacks% = 1
  :
  REPEAT
   manyattacks% += 1 : key$ = GET$
   attacks2%(manyattacks%-1) = TIME : VDU 7
  UNTIL key$ = "~" OR key$ = "`"
  :
  manyattacks% -= 1
  :
  FOR count% = 1 TO manyattacks% - 1
   attacks1%(count%) = attacks2%(count%)*960*MM%/6000
  NEXT
  :
  method$ = "raw"
  :
 ENDCASE
 REM ENDCASE 1
 :
 PROCinsertattacks
 :
 ENDPROC
 :
 REM***************************************************************
 :
 DEF PROCalterbeats
 :
 IF beats% < alterbeatsat% THEN beats% = beats% * beatfactor% * 8
 :
 ENDPROC
 :
 REM****************************************************************
 :
 DEF PROCdisarrayfill
 :
 FOR count% = 0 TO (cant%-1)
 :
 bar% = notategroup%(count%,0)DIV(10^6)
 carrybars% = (notategroup%(count%,1)DIV(10^4))-bar%
 carrybeats% = (notategroup%(count%,0)MOD(10^3))-((notategroup%(count%,0)MOD(10^6))DIV(10^3))
 grouplength% = (carrybars%*960)+carrybeats%
 grouplength% = grouplength%/beatfactor%
:
 beat% = ((notategroup%(count%,0)MOD(10^6))DIV(10^3))/beatfactor%
 divs% = notategroup%(count%,1)MOD(10^4)
:
 IF grouplength% > 99 OR divs% > 99 THEN bigirrat$ = "y" ELSE bigirrat$ = "n"
:
 IF (disarray%(bar%,0,voice%) DIV(10^3)) MOD10^2 = 0 AND bigirrat$ = "n" THEN
  hold% = disarray%(bar%,0,voice%)MOD10^3
  add% = ((beat%*(10^4)) + (grouplength%*(10^2)) + divs%) * (10^3)
  disarray%(bar%,0,voice%) = hold% + add%
 ELSE
 IF (disarray%(bar%,1,voice%)DIV(10^6))MOD10^2=0 AND bigirrat$ = "n" THEN
  disarray%(bar%,0,voice%)=disarray%(bar%,0,voice%)+(beat%*10)+(grouplength%DIV10)
  hold% = disarray%(bar%,1,voice%)MOD10^6
  add% = (((grouplength%MOD10)*100)+divs%)*10^6
  disarray%(bar%,1,voice%) = hold% + add%
  ELSE
 IF disarray%(bar%,1,voice%)MOD10^2=0 AND bigirrat$ = "n" THEN
  disarray%(bar%,1,voice%)=disarray%(bar%,1,voice%)+(beat%*(10^4))+(grouplength%*(10^2))+divs%
   ELSE
 IF (disarray%(bar%,2,voice%)DIV(10^3))MOD10^2 = 0 AND bigirrat$ = "n" THEN
  hold% = disarray%(bar%,2,voice%)MOD10^3
  add% = ((beat%*(10^4)) + (grouplength%*(10^2)) + divs%) * (10^3)
  disarray%(bar%,2,voice%)= hold% + add%
    ELSE
 IF disarray%(bar%,3,voice%)=0 THEN
  disarray%(bar%,3,voice%)=(beat%*10^7)+(grouplength%*10^4)+divs%
 ELSE
      VDU 7
      PRINT''''" THERE ARE ALREADY 5 RHYTHMIC GROUPS IN THIS BAR"
      PRINT"          (this is the maximum)"
      PRINT''"          TO CONTINUE PRESS C"
      CASE GET$ OF
       WHEN "C","c" : PROCawait
       OTHERWISE
        PROCawait
       ENDCASE
     ENDIF
    ENDIF
   ENDIF
  ENDIF
 ENDIF
 :
 NEXT
 :
 ENDPROC
 :
 REM**********************************************
 :
 DEF PROCdelete
 :
 PROCundoprepare
 :
 IF deleteone$ <> "none" THEN
  PROCdeleteone
 ELSE
 IF easiermenus$ = "n" THEN PROCwindow(20,69,80,55) ELSE PROCwindow(20,69,72,42)
 PRINT '" One or several notes LEAVING rhythmic notation  - A"
 PRINT '" One or several notes DELETING rhythmic notation - B"
 PRINT '" One or several bars                             - C"
 PRINT '" Whole voice                                     - D"
 PRINT '" Group of voices                                 - G"
 :
 CASE GET$ OF
  WHEN "A","a" :
  :
CLS
IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
:
  INPUT '" how many notes "numnotes%
  IF numnotes% = 0 THEN numnotes% = 1
IF quickcopy$ = "n" THEN
 PRINT'" Starting at bar number "
 INPUT " (press 0 for first bar displayed) "bar%
 IF bar% = 0 THEN bar% = startbar%
 INPUT " beat "beats% : PROCalterbeats
 start% = (bar%*(10^3))+beats%
ELSE
 INPUT ' " starting at note number "along%
IF along% = 0 THEN along% = 1
along%-=1
 copystartbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  copystartbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
beats% = copystartbeat%
PROCalterbeats
start% = (copystartbar%*(10^3))+beats%
ENDIF
PROCsearch(start%)
  PROCshuntleft(startcell%,numnotes%)
  :
ENDIF
:
  WHEN "B","b" :
  :
CLS
IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
:
 INPUT '" how many notes "numnotes%
:
IF quickcopy$ = "n" THEN
 PRINT'" Starting at bar number "
 INPUT " (press 0 for first bar displayed "bar%
 IF bar% = 0 THEN bar% = startbar%
 INPUT " beat "beats% : PROCalterbeats
 start% = (bar%*(10^3))+beats%
ELSE
 INPUT ' " starting at note number "along%
IF along% = 0 THEN along% = 1
along%-=1
 copystartbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  copystartbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
beats% = copystartbeat%
PROCalterbeats
start% = (copystartbar%*(10^3))+beats%
ENDIF
 PROCsearch(start%)
 FOR count% = startcell% TO (startcell%+(numnotes%-1))
 FOR counter% = 0 TO 1
  barno% = (array%(count%,0,voice%)DIV10^6)-counter%
 beatnum% = ((array%(count%,0,voice%)DIV10^3)MOD10^3)
 :
  group1start% = (disarray%(barno%,0,voice%)DIV10^7)*beatfactor%
  group1end% = group1start% + (((disarray%(barno%,0,voice%)DIV10^5)MOD10^2)*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group1start% AND beatnum%+(960*counter%) <= group1end% THEN
  disarray%(barno%,0,voice%) = disarray%(barno%,0,voice%)MOD10^3
 ENDIF
 :
 group2start% = ((disarray%(barno%,0,voice%)DIV10)MOD10^2)*beatfactor%
 group2end% = group2start%+((((disarray%(barno%,0,voice%)MOD10)*10)+(disarray%(barno%,1,voice%)DIV10^8))*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group2start% AND beatnum%+(960*counter%) <= group2end% THEN
  disarray%(barno%,0,voice%) = (disarray%(barno%,0,voice%)DIV10^3)*10^3
  disarray%(barno%,1,voice%) = disarray%(barno%,1,voice%)MOD10^6
 ENDIF
 :
 group3start%=((disarray%(barno%,1,voice%)DIV10^4)MOD10^2)*beatfactor%
 group3end% = group3start% + (((disarray%(barno%,1,voice%)MOD10^4)DIV10^2)*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group3start% AND beatnum%+(960*counter%) <= group3end% THEN
  disarray%(barno%,1,voice%) = (disarray%(barno%,1,voice%)DIV10^6)*10^6
 ENDIF
 :
 group4start% = (disarray%(barno%,2,voice%)DIV10^7)*beatfactor%
 group4end% = group4start%+(((disarray%(barno%,2,voice%)DIV10^5)MOD10^2)*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group4start% AND beatnum%+(960*counter%) <= group4end% THEN
  disarray%(barno%,2,voice%) =  disarray%(barno%,2,voice%)MOD10^3
 ENDIF
 :
 group5start% = (disarray%(barno%,3,voice%)DIV10^7)*beatfactor%
 group5end% = group5start%+(((disarray%(barno%,3,voice%)DIV10^4)MOD10^3)*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group5start% AND beatnum%+(960*counter%) <= group5end% THEN
 disarray%(barno%,2,voice%) = (disarray%(barno%,2,voice%)DIV10^3)*10^3
 disarray%(barno%,3,voice%) = 0
 ENDIF
 :
 NEXT
 :
 NEXT
 PROCshuntleft(startcell%,numnotes%)
 :
 WHEN "C","c" :
  CLS
  PRINT '" If rhythmic groups cross from the bar(s) in question "
  PRINT " to other bars, use A or B to delete those groups, "
  PRINT " in which case press X"
  PRINT'" Otherwise, press C to continue with deleting"
 PRINT" self-contained bar(s)"
  CASE GET$ OF
   WHEN "X","x" : PROCdelete
   OTHERWISE
  ENDCASE
 CLS
 INPUT '" how many bars (0 = 100) "NUMbars%
 IF NUMbars% = 0 THEN NUMbars% = 100
 PRINT '" starting at bar "
 INPUT  "(press 0 for first bar displayed) "STARTbar%
 IF STARTbar% = 0 THEN STARTbar% = startbar%
:
IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
 :
startcell% = 0
 :
FOR bar% = STARTbar% TO (STARTbar%+(NUMbars%-1))
 :
 IF numusedcells%(voice%)-startcell% > 0 THEN
 :
  start% = bar%*(10^3)
  IF start% < (array%(0,0,voice%)DIV10^3) THEN
   startcell% = 0
  ELSE PROCsearch(start%)
  ENDIF
 :
  numnotes% = 0
  WHILE (array%((startcell%+numnotes%),0,voice%)DIV10^6) = bar%
   numnotes% += 1
  ENDWHILE
  IF numnotes% > 0 THEN PROCshuntleft(startcell%,numnotes%)
 :
 FOR count% = 0 TO 3
  disarray%(bar%,count%,voice%) = 0
 NEXT
 :
 ENDIF
 :
 NEXT
 :
 WHEN "D","d" :
IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
 :
 FOR count% = 0 TO (numusedcells%(voice%)-1)
  array%(count%,0,voice%) = 0
  array%(count%,1,voice%) = 0
  array%(count%,2,voice%) = 0
 NEXT
 numusedcells%(voice%) = 0
 :
 FOR count% = 1 TO nobars%
  FOR counter% = 0 TO 3
   disarray%(count%,counter%,voice%) = 0
  NEXT
 NEXT
 :
WHEN "G","g" :
 INPUT'" Between which voice "voice1%
 INPUT'" and which voice "voice2%
 voice1% -= 1 : voice2% -= 1
 FOR whichvoice% = voice1% TO voice2%
  voice% = whichvoice%
  FOR count% = 0 TO (numusedcells%(voice%)-1)
   array%(count%,0,voice%) = 0
   array%(count%,1,voice%) = 0
   array%(count%,2,voice%) = 0
  NEXT
  numusedcells%(voice%) = 0
  FOR count% = 1 TO nobars%
   FOR counter% = 0 TO 3
    disarray%(count%,counter%,voice%) = 0
   NEXT
  NEXT
 NEXT
 :
 OTHERWISE VDU 7 : PROCdelete
 :
 ENDCASE
 PROCdisplay
 ENDPROC
 :
 REM************************************************
 :
 DEF PROCshuntleft(startcell%,numnotes%)
 :
 FOR count% = startcell% TO numusedcells%(voice%)-(numnotes%+1)
  array%(count%,0,voice%) = array%(count%+numnotes%,0,voice%)
  array%(count%,1,voice%) = array%(count%+numnotes%,1,voice%)
  array%(count%,2,voice%) = array%(count%+numnotes%,2,voice%)
 NEXT
 FOR count% = (numusedcells%(voice%)-1) TO (numusedcells%(voice%)-numnotes%) STEP -1
  array%(count%,0,voice%) = 0
  array%(count%,1,voice%) = 0
  array%(count%,2,voice%) = 0
 NEXT
 numusedcells%(voice%) = numusedcells%(voice%)-numnotes%
 ENDPROC
 :
 REM********************************************************
 :
 DEF PROCpredisplay
 :
 CLS
 methd$ = "second"
 INPUT '" How many bars "numbars%
 INPUT '" starting at bar "startbar%
 INPUT '" How many voices "numvoices%
 :
 requestedend% = startbar% + numbars%
 :
 IF requestedend% > nobars% THEN startbar% -= (requestedend%-nobars%)
 IF startbar% < 1 THEN
  startbar% = 1 : numbars% = nobars%-1
 ENDIF
 IF numvoices% > numparts% THEN numvoices% = numparts%
 holdnum% = numvoices%
 :
 IF numvoices% > 9 THEN
  PRINT '" Are the voice numbers"
  PRINT  " successive?"
  CASE GET$ OF
   WHEN "Y","y" :
    INPUT " starting at voice number "vce%
    FOR count% = 1 TO numvoices%
     displayvoices%(count%) = vce% + count% - 1
     holddisplay%(count%) = vce% + count% - 1
    NEXT
    methd$ = "first"
   OTHERWISE
  ENDCASE
 ENDIF
 IF methd$ = "second" THEN
 FOR count% = 1 TO numvoices%
  PRINT '"  voice ";count%;
 INPUT " is voice "vce%
 displayvoices%(count%) = vce%
 holddisplay%(count%) = vce%
 NEXT
 ENDIF
 startv% = 1 : holdstart% = 1
 PROCdisplay
 ENDPROC
 :
 REM********************************************
 :
 DEF PROCquickdisplay
 :
  FOR count% = 1 TO quicknum%
   prequickdisplay%(count%) = quickdisplay%(count%)
  NEXT
   prequicknum% = quicknum%
  :
  IF quickdisplaywindow$ = "y" THEN
   PROCwindow(20,63,48,55) : ON
  ENDIF
  :
  IF numvoicesgiven$ = "n" THEN
  REPEAT
  INPUT'" How many voices "numvoices%
  UNTIL numvoices% > 0 : REM stops a crash if 0 accidentally input
  quicknum% = numvoices%
  ENDIF
  :
  IF numvoices% > 1 THEN
  PRINT'" Are the voices successive "
  CASE GET$ OF
   WHEN "N","n","2" : succ$ = "n"
   OTHERWISE succ$ = "y"
  ENDCASE
  ELSE
   succ$ = "n"
  ENDIF
  :
  IF succ$ = "y" THEN
  INPUT'" starting at voice "vce%
  FOR count% = 1 TO numvoices%
   displayvoices%(count%) = vce%+count%-1
   quickdisplay%(count%) = vce%+count%-1
  NEXT
  :
  ELSE
  FOR count% = 1 TO numvoices%
   IF numvoices% = 1 THEN
    PRINT'" which voice "
   ELSE
    PRINT'" voice ";count%;" is voice "
   ENDIF
   REPEAT
   INPUT vce%
   UNTIL vce% > 0
   displayvoices%(count%) = vce%
   quickdisplay%(count%) = vce%
  NEXT
  ENDIF
  :
  quicknum% = numvoices%
  startv% = 1
  toggle$ = "quick" : numvoicesgiven$ = "n"
  quickdisplaywindow$ = "y"
  PROCdisplay
 ENDPROC
 :
 REM********************************************
 :
 DEF PROCdisplay
 :
 *CONFIGURE ScreenSize 256K
 MODE 31
 VDU 5
 ledgerkey% = 1 : height1% = 0 : wideness1% = 0 : along% = 0
 :
VDU 23,17,7,6,7;7;0;
REM penultimate and pre-penultimate values determine text size
:
 endv% = startv% + numvoices% - 1
 IF longscore$ = "y" AND (endv%-startv%)>2 THEN endv% = startv%+2
 :
 IF printing$ = "n" THEN
  GCOL 0 : GCOL 191 : CLG
  ELSE
   GCOL 0 : GCOL 191 : CLG
 ENDIF
 :
 REM display of beatnumbers, notenumbers etc shuffle up to occupy empty space
 beatsheight% = 0 : numbersheight% = 0 : intheight% = 0
 IF amplitudes$ = "y" THEN
  beatsheight% += 40 : numbersheight% += 40 : intheight% += 40
 ENDIF
 IF beatnumbers$ = "y" THEN
  numbersheight% += 40 : intheight% += 40
 ENDIF
 IF notenumbers$ = "y" OR notenumbers$ = "from1" THEN intheight% += 40
 :
 IF longscore$ = "n" THEN width% = 1520 ELSE width% = 1480
 IF printing$ = "y" THEN width% -= 0
 factor = width%/((numbars%/2)*960)
 IF longscore$ = "y" THEN factor = factor/2
 :
 REM stave lines, barlines & beats for shortscore
 IF longscore$ = "n" THEN
 IF staves$ = "y" THEN
 FOR count% = 938 TO 874 STEP -16 : LINE 0,count%,2112,count% : NEXT
 IF lowerstave$ = "y" THEN
 FOR count% = 794 TO 730 STEP -16 : LINE 0,count%,2112,count% : NEXT
 ENDIF
 FOR count% = 414 TO 350 STEP -16 : LINE 0,count%,2112,count% : NEXT
 IF lowerstave$ = "y" THEN
 FOR count% = 270 TO 206 STEP -16 : LINE 0,count%,2112,count% : NEXT
 ENDIF
 ENDIF
 :
 REM barlines
 IF barlines$ = "y" THEN
  FOR system% = 0 TO 1
   FOR barline% = 1 TO (numbars%/2)
    horpos% = (960*barline%*factor)+40
   IF notehead$ = "small" THEN horpos% += 16
   IF notehead$ = "vsmall" THEN horpos% += 24
    FOR thickness% = 2 TO 8 STEP 2
     LINE horpos%+thickness%,874-(524*system%),horpos%+thickness%,794-(524*system%)
    NEXT
    REM bar nos
    IF printing$ = "n" THEN GCOL 3
IF tempi%(startbar%) <> tempi%(startbar%-1) THEN
    MOVE 40,1145 : PRINT "b.";startbar%;" MM.";tempi%(startbar%)
ELSE MOVE 40,1145 : PRINT "b.";startbar%;" (MM.";tempi%(startbar%);")"
ENDIF
IF remarks$(startbar%,0) <> "" OR remarks$(startbar%,1) <> "" THEN
MOVE 40,1120 : PRINT remarks$(startbar%,0) : MOVE 40,1095 : PRINT remarks$(startbar%,1)
ENDIF
    IF printing$ = "n" THEN GCOL 0
    barline1% = (system%*(numbars%/2))+barline%
     MOVE horpos%-125,1145-(533*system%)
    IF printing$ = "n" THEN GCOL 3
    IF tempi%(startbar% + barline1%) <> tempi%(startbar% + barline1% - 1) THEN
     PRINT startbar% + barline1%;" MM.";tempi%(startbar% + barline1%);
    ELSE IF barline1% MOD barnosoften% = 0 THEN PRINT startbar% + barline1%
    ENDIF
IF remarks$(startbar%+barline1%,0) <> "" OR remarks$(startbar%+barline1%,1) <> "" THEN
MOVE horpos%,1120-(533*system%) : PRINT remarks$(startbar%+barline1%,0)
MOVE horpos%,1095-(533*system%) : PRINT remarks$(startbar%+barline1%,1)
ENDIF
REM print duration at bottom right
IF seeduration$ = "y" THEN
IF startbar% + barline1% = startbar% + numbars% - 1 THEN
totaldur = 0
FOR count% = 1 TO startbar% + numbars% - 1
duration = 60/tempi%(count%)
totaldur = totaldur + duration
NEXT
totaldur% = totaldur
mins% = totaldur% DIV 60
secs% = totaldur% - (mins%*60)
MOVE 1200,50 : PRINT "duration ";mins%;" mins ";secs%;" secs"
ENDIF
ENDIF
    IF printing$ = "n" THEN GCOL 0
   NEXT
  NEXT
    REM bar no for system 2 first bar
     MOVE -70,612
    IF printing$ = "n" THEN GCOL 3
    IF tempi%(startbar%+(numbars%/2)) <> tempi%(startbar%+(numbars%/2)-1) THEN
     PRINT startbar%+(numbars%/2);" MM.";tempi%(startbar%+(numbars%/2))
     ELSE IF (numbars%/2) MOD barnosoften% = 0 THEN PRINT startbar%+(numbars%/2)
    ENDIF
IF remarks$(startbar%+(numbars%/2),0) <> "" OR remarks$(startbar%+(numbars%/2),1) <> "" THEN
MOVE 40,587 : PRINT remarks$(startbar%+(numbars%/2),0)
MOVE 40,562 : PRINT remarks$(startbar%+(numbars%/2),1)
ENDIF
    IF printing$ = "n" THEN GCOL 0
 ENDIF
 :
 REM beats
 IF beats$ = "y" THEN
  IF notehead$ = "big" THEN add% = 26
  IF notehead$ = "small" THEN add% = 34
  IF notehead$ = "vsmall" THEN add% = 38
  :
  FOR system% = 0 TO 1
   FOR br% = 0 TO (numbars%/2)-1
    horpos% = (960*br%*factor)+add%+40
    FOR bt% = 0 TO (factor%-1) STEP beatstep%
     CIRCLE horpos%+(bt%*960/factor%*factor),834-(524*system%),4
    NEXT
   NEXT
  NEXT
 ENDIF
 :
 ENDIF
 :
 REM staves, barlines, beats etc for longscore
 IF longscore$ = "y" THEN
 longinsts$() = ""
  REM staves
  lastcount% = numvoices%-1
  IF lastcount% > 2 THEN lastcount% = 2
  FOR count% = 0 TO lastcount%
   longinsts$(count%,0) = insts$(displayvoices%(startv%+count%),0)
   longinsts$(count%,1) = insts$(displayvoices%(startv%+count%),1)
   longinsts$(count%,2) = insts$(displayvoices%(startv%+count%),2)
  NEXT
  stavecombination$  = longinsts$(0,2) + longinsts$(1,2) + longinsts$(2,2)
  clefcombination$ = longinsts$(0,1)+longinsts$(1,1)+longinsts$(2,1)
  CASE stavecombination$ OF
   WHEN "111" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,604-count%,2112,604-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,270-count%,2112,270-count% : NEXT
  ENDIF
    PROCclef(3,938,604,270,0,0,0,clefcombination$)
    PROClongvalue(938,604,270,clefcombination$)
   WHEN "121" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,652-count%,2112,652-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,556-count%,2112,556-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,270-count%,2112,270-count% : NEXT
  ENDIF
    PROCclef(4,938,652,556,270,0,0,clefcombination$)
    PROClongvalue(938,652,270,clefcombination$)
   WHEN "211" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,842-count%,2112,842-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,556-count%,2112,556-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,270-count%,2112,270-count% : NEXT
  ENDIF
    PROCclef(4,938,842,556,270,0,0,clefcombination$)
    PROClongvalue(938,556,270,clefcombination$)
   WHEN "112" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,652-count%,2112,652-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,366-count%,2112,366-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,270-count%,2112,270-count% : NEXT
  ENDIF
    PROCclef(4,938,652,366,270,0,0,clefcombination$)
    PROClongvalue(938,652,366,clefcombination$)
   WHEN "221" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,842-count%,2112,842-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,604-count%,2112,604-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,508-count%,2112,508-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,270-count%,2112,270-count% : NEXT
  ENDIF
    PROCclef(5,938,842,604,508,270,0,clefcombination$)
    PROClongvalue(938,604,270,clefcombination$)
   WHEN "222" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,842-count%,2112,842-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,652-count%,2112,652-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,556-count%,2112,556-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,366-count%,2112,366-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,270-count%,2112,270-count% : NEXT
  ENDIF
    PROCclef(6,938,842,652,556,366,270,clefcombination$)
    PROClongvalue(938,652,366,clefcombination$)
   WHEN "122" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,700-count%,2112,700-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,604-count%,2112,604-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,366-count%,2112,366-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,270-count%,2112,270-count% : NEXT
  ENDIF
    PROCclef(5,938,700,604,366,270,0,clefcombination$)
    PROClongvalue(938,700,366,clefcombination$)
   WHEN "212" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,842-count%,2112,842-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,604-count%,2112,604-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,366-count%,2112,366-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,270-count%,2112,270-count% : NEXT
  ENDIF
    PROCclef(5,938,842,604,366,270,0,clefcombination$)
    PROClongvalue(938,604,366,clefcombination$)
   WHEN "1" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
  ENDIF
    PROCclef(1,938,0,0,0,0,0,clefcombination$)
    PROClongvalue(938,0,0,clefcombination$)
   WHEN "2" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,842-count%,2112,842-count% : NEXT
  ENDIF
    PROCclef(2,938,842,0,0,0,0,clefcombination$)
    PROClongvalue(938,0,0,clefcombination$)
   WHEN "11" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,604-count%,2112,604-count% : NEXT
  ENDIF
    PROCclef(2,938,604,0,0,0,0,clefcombination$)
    PROClongvalue(938,604,0,clefcombination$)
   WHEN "12" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,652-count%,2112,652-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,556-count%,2112,556-count% : NEXT
  ENDIF
    PROCclef(3,938,652,556,0,0,0,clefcombination$)
    PROClongvalue(938,652,0,clefcombination$)
   WHEN "21" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,842-count%,2112,842-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,556-count%,2112,556-count% : NEXT
  ENDIF
    PROCclef(3,938,842,556,0,0,0,clefcombination$)
    PROClongvalue(938,556,0,clefcombination$)
   WHEN "22" :
  IF staves$ = "y" THEN
    FOR count% = 0 TO 64 STEP16 : LINE 0,938-count%,2112,938-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,842-count%,2112,842-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,556-count%,2112,556-count% : NEXT
    FOR count% = 0 TO 64 STEP16 : LINE 0,460-count%,2112,460-count% : NEXT
  ENDIF
    PROCclef(4,938,842,556,460,0,0,clefcombination$)
    PROClongvalue(938,556,0,clefcombination$)
  ENDCASE
 :
 REM time signature
 beatstothebar% = (960/beatfactor%)/8
 CASE beams% OF
 WHEN 1 : whichvalue% = 1
 WHEN 2 : whichvalue% = 2
 WHEN 3 : whichvalue% = 4
 WHEN 4 : whichvalue% = 8
 WHEN 5 : whichvalue% = 16
 WHEN 6 : whichvalue% = 32
 ENDCASE
 MOVE 15,1050
  PRINT "meter"
  MOVE 15,1030
 PRINT" ";beatstothebar%;"/";whichvalue%
 :
 REM beats
 IF beats$ = "y" THEN
  IF notehead$ = "big" THEN add% = 26
  IF notehead$ = "small" THEN add% = 34
  IF notehead$ = "vsmall" THEN add% = 38
 :
   FOR br% = 0 TO (numbars%-1)
    horpos% = (960*br%*factor)+add%+80
    FOR bt% = 0 TO (factor%-1) STEP beatstep%
     CIRCLE horpos%+(bt%*960/factor%*factor),longbeatsupper%,4:CIRCLE horpos%+(bt%*960/factor%*factor),longbeatslower%,4
    NEXT
   NEXT
 ENDIF
 ENDIF
 :
 IF longscore$ = "n" THEN number% = 2 ELSE number% = 1
 FOR system% = 1 TO number%
 :
 FOR count% = startv% TO endv%
 :
 voice% = (displayvoices%(count%))-1
 addingnotes$ = "n"
 current% = 0 : lowernumber% = 0
 IF system% = 1 THEN firstbar% = startbar%
 IF system% = 2 THEN firstbar% = startbar%+(numbars%/2)
 PROCnewnotereception(voice%,firstbar%,0,0,0,0,0,0,0)
 CASE option% OF
  WHEN 1 : startcell% = 0
  WHEN 2 : startcell% = numusedcells%(voice%)
   WHEN 3 : startcell% = 0
  WHEN 4 : start% = firstbar%*10^3 : PROCsearch(start%)
 ENDCASE
 holdstartcell%(voice%) = startcell%
 :
 IF array%(startcell%,0,voice%)DIV10^6 > 0 THEN
 :
 howmany% = 0
 REPEAT
 howmany% += 1
 :
 carrybars% = (array%(startcell%,0,voice%)DIV10^6) - firstbar%
 beat% = ((array%(startcell%,0,voice%)DIV10^3)MOD10^3)+(carrybars%*960)
 hposn% = (beat%*factor)+50  : REM gives horiz co-ordinate
 :
 IF howmany% = 1 THEN firsttrack% = hposn%
 :
 IF longscore$ = "y" THEN hposn% += 40
 :
 octave% = (array%(startcell%,0,voice%)MOD10)
  IF longscore$ = "n" THEN
   IF octave% < 4 AND system% = 1 THEN value% = 586
   IF octave% >= 4 AND system% = 1 THEN value% = 858
   IF octave% < 4 AND system% = 2 THEN value% = 62
   IF octave% >= 4 AND system% = 2 THEN value% = 334
   IF octave% > 3 THEN octave% = octave%-4
  ENDIF
  :
  ENDCASE
 IF longscore$ = "y" THEN value% = value%(count%-startv%)
 :
 vposn% = value%+(((array%(startcell%,0,voice%)MOD10^3)DIV10^2)*8)+(octave%*56)  : REM gives vert co-ordinate
 :
 REM notehead
 IF redpitches$ = "y" THEN PROCredpitches
 IF notehead$ = "big" THEN
 LINE hposn%+12,vposn%+8,hposn%+26,vposn%+8
 LINE hposn%+4,vposn%+4,hposn%+30,vposn%+4
 LINE hposn%,vposn%,hposn%+32,vposn%
 LINE hposn%+2,vposn%-4,hposn%+28,vposn%-4
 LINE hposn%+6,vposn%-8,hposn%+20,vposn%-8
 ENDIF
 IF notehead$ = "small" THEN
 LINE hposn%+24,vposn%+8,hposn%+28,vposn%+8
 LINE hposn%+20,vposn%+4,hposn%+30,vposn%+4
 LINE hposn%+16,vposn%,hposn%+32,vposn%
 LINE hposn%+18,vposn%-4,hposn%+28,vposn%-4
 LINE hposn%+20,vposn%-8,hposn%+24,vposn%-8
 ENDIF
 IF notehead$ = "vsmall" THEN
 LINE hposn%+28,vposn%+8,hposn%+28,vposn%+8
 LINE hposn%+27,vposn%+6,hposn%+29,vposn%+6
 LINE hposn%+26,vposn%+4,hposn%+30,vposn%+4
 LINE hposn%+25,vposn%+2,hposn%+31,vposn%+2
 LINE hposn%+24,vposn%,hposn%+32,vposn%
 LINE hposn%+25,vposn%-2,hposn%+31,vposn%-2
 LINE hposn%+26,vposn%-4,hposn%+30,vposn%-4
 LINE hposn%+27,vposn%-6,hposn%+29,vposn%-6
 LINE hposn%+28,vposn%-8,hposn%+28,vposn%-8
 ENDIF
 IF printing$ = "n" THEN GCOL 0
 :
 REM beatnumbers
 IF beatnumbers$ = "y" OR (beatnumbers$ = "first" AND howmany% = 1) THEN
 PROCnotenumbersep
 IF longscore$ = "y" THEN
  MOVE hposn%-100,actamppos%(voice%+1)-beatsheight%-lower%-lowernumber%
  PROCbeatnumbers
 ELSE MOVE hposn%-100,674+shortamppos%(voice%)-((system%-1)*524)-beatsheight%+40-lower%
  PROCbeatnumbers
 ENDIF
 ENDIF
 :
 REM notenumbers
 IF notenumbers$ = "y" THEN
  PROCnotenumbersep
  IF longscore$ = "y" THEN
   MOVE hposn%-100,actamppos%(voice%+1)-numbersheight%-lowernumber%
   PRINT startcell%+1
  ELSE MOVE hposn%-100,(674+shortamppos%(voice%)-((system%-1)*524))-numbersheight%+40
   PRINT startcell%+1
  ENDIF
 ENDIF
:
 IF notenumbers$ = "last" THEN
  IF (array%(startcell%+1,0,voice%) DIV10^6) >= (numbars%+firstbar%) OR array%(startcell%+1,0,voice%) = 0 THEN print$ = "y" ELSE print$ = "n"
   IF print$ = "y" THEN
   MOVE hposn%-100,actamppos%(voice%+1)-numbersheight%
   PRINT startcell%+1
   ENDIF
 ENDIF
:
 IF notenumbers$ = "from1" THEN
  PROCnotenumberfreq
  PROCnotenumbersep
  IF printnumber$ = "y" THEN
  IF longscore$ = "y" THEN
   MOVE hposn%-100,actamppos%(voice%+1)-numbersheight%-lowernumber%
    PRINT howmany%
   ELSE MOVE hposn%-100,(674+shortamppos%(voice%)-((system%-1)*524))-numbersheight%+40
   PRINT howmany%
  ENDIF
  ENDIF
 ENDIF
 :
 REM intervals
 IF displayintervals$ = "y" THEN
   pitch% = array%(startcell%,0,voice%)MOD10^3
   CASE typeintervals$ OF
    WHEN "s" : PROCconvertpitch
    WHEN "q" : PROCconvertquarter
    WHEN "e" : PROCconverteighth
    WHEN "c" : cent% = (array%(startcell%,2,voice%)MOD10^2)-50 : PROCconvertcent
    OTHERWISE
   ENDCASE
   currentpitch% = note%
  FOR cout% = 1 TO numintervals%
   IF (startcell%-cout%) >= 0 THEN
     pitch% = array%((startcell%-cout%),0,voice%)MOD10^3
     CASE typeintervals$ OF
      WHEN "s" : PROCconvertpitch
      WHEN "q" : PROCconvertquarter
      WHEN "e" : PROCconverteighth
      WHEN "c" : cent% = (array%((startcell%-cout%),2,voice%)MOD10^2)-50  : PROCconvertcent
      OTHERWISE
     ENDCASE
     comparepitch% = note%
    IF currentpitch% >= comparepitch% THEN
      interval% = currentpitch% - comparepitch%
    ELSE interval% = comparepitch% - currentpitch%
    ENDIF
   REPEAT : IF interval% > compoundint% THEN interval% -= chunk% : UNTIL interval% <= compoundint%
    IF longscore$ = "y" THEN
       MOVE hposn%-125,actamppos%(voice%+1)-(intheight%+(40*(cout%-1)))
       PRINT interval%
    ELSE MOVE hposn%-125,(674+shortamppos%(voice%)-((system%-1)*524))-(intheight%+(40*(cout%-1))-40)
       PRINT interval%
    ENDIF
   ENDIF
  NEXT
 ENDIF
 :
 REM note names
 IF notenames$ = "y" THEN
 whichnote% = (array%(startcell%,0,voice%)MOD10^3)DIV10^2
 CASE whichnote% OF
  WHEN 0 : name$ = "C"
  WHEN 1 : name$ = "D"
  WHEN 2 : name$ = "E"
  WHEN 3 : name$ = "F"
  WHEN 4 : name$ = "G"
  WHEN 5 : name$ = "A"
  WHEN 6 : name$ = "B"
  OTHERWISE
 ENDCASE
 MOVE hposn%+10,actamppos%(voice%+1)-(numbersheight%+32)
 PRINT name$;array%(startcell%,0,voice%)MOD10
 ENDIF
:
 REM durations/glissandos
 IF durations$ = "y" THEN
  dur% = (array%(startcell%,1,voice%)DIV10)MOD10^3
  brrr% = array%(startcell%,0,voice%)DIV10^6 : PROCreconvertdur
  IF notehead$ = "big" THEN pointplus% = 16
  IF notehead$ = "small" THEN pointplus% = 24
  IF notehead$ = "vsmall" THEN pointplus% = 28
  point% = (dur%*factor)+hposn%+pointplus%
  thirdphase$ = "n"
 :
 number% = array%(startcell%,2,voice%)DIV10^5
 IF number% = 0 THEN numphases% = 1
 IF number% > 0 AND number% < 100 THEN numphases% = 2
 IF number% > 99 THEN numphases% = 3
 :
 CASE numphases% OF
  :
  WHEN 1 :
   gl% = (array%(startcell%,1,voice%)DIV10^4)MOD10^2
   IF gl% <> 50 THEN
    PROCroundgliss
    LINE hposn%+40,vposn%+4,point%,vposn%+4+gl%
    hp% = ((point%-hposn%)/2)+hposn%
    vp% = vposn%+44+(gl%/2)
    MOVE hp%,vp% : PRINT "gl.";gl1%
   ELSE
    LINE hposn%+40,vposn%+4,point%,vposn%+4
   ENDIF
  :
  WHEN 2 :
   REM extra horizontal point in middle
   ph1% = number% MOD 10^2
   point1% = ((dur%*ph1%/100)*factor)+hposn%+pointplus%
   :
   REM first phase
   gl% = (array%(startcell%,1,voice%)DIV10^4)MOD10^2
   IF gl% <> 50 THEN
    PROCroundgliss
    LINE hposn%+40,vposn%+4,point1%,vposn%+4+gl%
    hp% = ((point1%-hposn%)/2)+hposn%
    vp% = vposn%+44+(gl%/2)
    MOVE hp%,vp% : PRINT "gl.";gl1%
   ELSE
    gl% = 0
    LINE hposn%+40,vposn%+4,point1%,vposn%+4
   ENDIF
IF envelopedata$ <> "none" THEN
   hp% = point1%-130
   vp% = vposn%-10
   MOVE hp%,vp%
CASE envelopedata$ OF
WHEN "percentage" :PRINT ph1%;"%"
WHEN "marker" : PRINT hp%
ENDCASE
ENDIF
   :
   REM second phase
   vposn1% = vposn%+gl%
   gl% = (array%(startcell%,1,voice%)DIV10^6)MOD10^2
   IF gl% <> 50 THEN
    PROCroundgliss
    LINE point1%,vposn1%+4,point%,vposn1%+4+gl%
    hp% = ((point%-point1%)/2)+point1%
    vp% = vposn1%+44+(gl%/2)
    MOVE hp%,vp% : PRINT "gl.";gl1%
   ELSE
    LINE point1%,vposn1%+4,point%,vposn1%+4
   ENDIF
  :
  WHEN 3 :
   REM two extra horizontal points in middle
   ph1% = number% MOD 10^2
   point1% = ((dur%*ph1%/100)*factor)+hposn%+pointplus%
   ph2% = number% DIV 10^2
   point2% = ((dur%*ph2%/100)*factor)+hposn%+pointplus%
   :
   REM first phase
   gl% = (array%(startcell%,1,voice%)DIV10^4)MOD10^2
   IF gl% <> 50 THEN
    PROCroundgliss
    LINE hposn%+40,vposn%+4,point1%,vposn%+4+gl%
    hp% = ((point1%-hposn%)/2)+hposn%
    vp% = vposn%+44+(gl%/2)
    MOVE hp%,vp% : PRINT "gl.";gl1%
   ELSE
    gl% = 0
    LINE hposn%+40,vposn%+4,point1%,vposn%+4
   ENDIF

IF envelopedata$ <> "none" THEN
   hp% = point1%-130
   vp% = vposn%-10
   MOVE hp%,vp%
CASE envelopedata$ OF
WHEN "percentage" :PRINT ph1%;"%"
WHEN "marker" : PRINT hp%
ENDCASE
ENDIF
   :
   REM second phase
   vposn1% = vposn%+gl%
   gl% = (array%(startcell%,1,voice%)DIV10^6)MOD10^2
   IF gl% <> 50 THEN
    PROCroundgliss
    LINE point1%,vposn1%+4,point2%,vposn1%+4+gl%
    hp% = ((point2%-point1%)/2)+point1%
    vp% = vposn1%+44+(gl%/2)
    MOVE hp%,vp% : PRINT "gl.";gl1%
   ELSE
    gl% = 0
    LINE point1%,vposn1%+4,point2%,vposn1%+4
   ENDIF

IF envelopedata$ <> "none" THEN
   hp% = point2%-130
   vp% = vposn%-10
   MOVE hp%,vp%
CASE envelopedata$ OF
WHEN "percentage" :PRINT ph2%;"%"
WHEN "marker" : PRINT hp%
ENDCASE
ENDIF
   :
   REM third phase
   vposn2% = vposn1%+gl%
   gl% = array%(startcell%,1,voice%)DIV10^8
   IF gl% <> 10 THEN
    thirdphase$ = "y" : PROCroundgliss : thirdphase$ = "n"
    LINE point2%,vposn2%+4,point%,vposn2%+4+gl%
    hp% = ((point%-point2%)/2)+point2%
    vp% = vposn2%+44+(gl%/2)
    MOVE hp%,vp% : PRINT "gl.";gl1%
   ELSE
    LINE point2%,vposn2%+4,point%,vposn2%+4
   ENDIF
   :
 ENDCASE
 :
 ENDIF
 :
REM next block of code added just to print durations
IF seedurinbts$ = "y" OR seedurinbts$ = "stepped" THEN
IF seedurinbts$ = "stepped" THEN
 IF lower% = 0 THEN lower% = 23 ELSE lower% = 0
 ENDIF
 IF longscore$ = "y" THEN
  MOVE hposn%,actamppos%(voice%+1)-lower%
  PRINT dur%
 ELSE MOVE hposn%,714+shortamppos%(voice%)-((system%-1)*524)-lower%
  PRINT dur%
 ENDIF
ENDIF
IF seedurincrots$ = "y" OR seedurincrots$ = "stepped" THEN
REM dur = (((dur%/480)*100)DIV1)/100
dur = (((dur%/(beatfactor%*8))*100)DIV1)/100
IF seedurincrots$ = "stepped" THEN
 IF lower% = 0 THEN lower% = 23 ELSE lower% = 0
 ENDIF
 IF longscore$ = "y" THEN
  MOVE hposn%,actamppos%(voice%+1)-lower%
  PRINT dur
 ELSE MOVE hposn%,714+shortamppos%(voice%)-((system%-1)*524)-lower%
  PRINT dur
 ENDIF
ENDIF
:
 REM amplitudes
:

 IF amplitudes$ = "y" OR amplitudes$ = "stepped" THEN
 amp$=""
 amp1% = array%(startcell%,1,voice%)MOD10
 amp2% = (array%(startcell%,2,voice%)DIV10^2)MOD10
 amp3% = (array%(startcell%,2,voice%)DIV10^3)MOD10
 amp4% = (array%(startcell%,2,voice%)DIV10^4)MOD10
 FOR something% = 1 TO 4
  IF something% = 1 THEN amp% = amp1%
  IF something% = 2 THEN amp% = amp2%
  IF something% = 3 THEN amp% = amp3%
  IF something% = 4 THEN amp% = amp4%
  CASE amp% OF
   WHEN 0 :
     IF amp1% = 0 AND amp2% = 9 THEN
      amp$ = "" : x% = 22 : y% = 20 : REM releases
     ELSE
      amp$ = "0" : x% = 22 : y% = 20
     ENDIF
   WHEN 1 : amp$ = "ppp" : x% = 8 : y% = 50
   WHEN 2 : amp$ = "pp" : x% = 15 : y% = 35
   WHEN 3 : amp$ = "p" : x% = 22 : y% = 20
   WHEN 4 : amp$ = "mp" : x% = 15 : y% = 35
   WHEN 5 : amp$ = "mf" : x% = 15 : y% = 35
   WHEN 6 : amp$ = "f" : x% = 22 : y% = 20
   WHEN 7 : amp$ = "ff" : x% = 15 : y% = 35
   WHEN 8 : amp$ = "fff" : x% = 8 : y% = 50
  ENDCASE
  IF something% = 1 THEN amp1$ = amp$ : x1% = x% : y1% = y%
  IF something% = 2 THEN amp2$ = amp$ : x2% = x% : y2% = y%
  IF something% = 3 THEN amp3$ = amp$ : x3% = x% : y3% = y%
  IF something% = 4 THEN amp4$ = amp$ : x4% = x% : y4% = y%
 NEXT
 :
 IF amplitudes$ = "stepped" THEN
 IF lower% = 0 THEN lower% = 23 ELSE lower% = 0
 ENDIF
 :
 IF longscore$ = "y" THEN
  MOVE hposn%+x1%,actamppos%(voice%+1)-lower%
  PRINT amp1$
:
IF amp2% = 9 AND amp3% <> 0 THEN
MOVE hposn%+20,(actamppos%(voice%+1)-lower%)-20
PRINT "+";amp3%
ENDIF
:

 ELSE MOVE hposn%+x1%,714+shortamppos%(voice%)-((system%-1)*524)-lower%
  PRINT amp1$

 ENDIF
 :
  dur% = (array%(startcell%,1,voice%)DIV10)MOD10^3
  brrr% = array%(startcell%,0,voice%)DIV10^6 : PROCreconvertdur
  IF notehead$ = "big" THEN pointplus% = 16
  IF notehead$ = "small" THEN pointplus% = 24
  IF notehead$ = "vsmall" THEN pointplus% = 28
  point% = (dur%*factor)+hposn%+pointplus%
  :
 number% = array%(startcell%,2,voice%)DIV10^5
 IF amp2% = 9 THEN numphases% = 0
 IF amp2% <> 9 AND number% = 0 THEN numphases% = 1
 IF number% > 0 AND number% < 100 THEN numphases% = 2
 IF number% > 99 THEN numphases% = 3
 :
 CASE numphases% OF
  :
  WHEN 1 :
    IF amp2% < amp1% THEN
        IF longscore$ = "y" THEN
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)+8,point%-90+(x2%*2),actamppos%(voice%+1)-8
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)-24,point%-90+(x2%*2),actamppos%(voice%+1)-8
        MOVE point%-80+(x2%*2),actamppos%(voice%+1) : PRINT amp2$
        ELSE LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)+8,point%-90+(x2%*2),714+shortamppos%(voice%)-((system%-1)*524)-8
        LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)-24,point%-90+(x2%*2),714+shortamppos%(voice%)-((system%-1)*524)-8
        MOVE point%-80+(x2%*2),714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp2$
        ENDIF
    ENDIF
    IF amp2% > amp1% THEN
        IF longscore$ = "y" THEN
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)-8,point%-90+(x2%*2),actamppos%(voice%+1)+8
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)-8,point%-90+(x2%*2),actamppos%(voice%+1)-24
        MOVE point%-80+(x2%*2),actamppos%(voice%+1) : PRINT amp2$
        ELSE LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)-8,point%-90+(x2%*2),714+shortamppos%(voice%)-((system%-1)*524)+8
        LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)-8,point%-90+(x2%*2),714+shortamppos%(voice%)-((system%-1)*524)-24
        MOVE point%-80+(x2%*2),714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp2$
        ENDIF
    ENDIF
    :
  WHEN 2 :
    ph1% = number% MOD 10^2
    point1% = ((dur%*ph1%/100)*factor)+hposn%+pointplus%
    :
    REM first phase
    IF amp2% < amp1% THEN
        IF longscore$ = "y" THEN
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)+8,point1%-35+x2%,actamppos%(voice%+1)-8
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)-24,point1%-35+x2%,actamppos%(voice%+1)-8
        MOVE point1%-25+x2%,actamppos%(voice%+1) : PRINT amp2$
        ELSE LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)+8,point1%-35+x2%,714+shortamppos%(voice%)-((system%-1)*524)-8
        LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)-24,point1%-35+x2%,714+shortamppos%(voice%)-((system%-1)*524)-8
        MOVE point1%-25+x2%,714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp2$
        ENDIF
    ENDIF
    IF amp2% > amp1% THEN
        IF longscore$ = "y" THEN
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)-8,point1%-35+x2%,actamppos%(voice%+1)+8
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)-8,point1%-35+x2%,actamppos%(voice%+1)-24
        MOVE point1%-25+x2%,actamppos%(voice%+1) : PRINT amp2$
        ELSE LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)-8,point1%-35+x2%,714+shortamppos%(voice%)-((system%-1)*524)+8
        LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)-8,point1%-35+x2%,714+shortamppos%(voice%)-((system%-1)*524)-24
        MOVE point1%-25+x2%,714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp2$
        ENDIF
    ENDIF
    :
    REM second phase
    IF amp1% <> amp2% THEN start% = point1%-25+x2%+y2% ELSE start% = point1%
    IF amp3% < amp2% THEN
        IF longscore$ = "y" THEN
        LINE start%,actamppos%(voice%+1)+8,point%-90+(x3%*2),actamppos%(voice%+1)-8
        LINE start%,actamppos%(voice%+1)-24,point%-90+(x3%*2),actamppos%(voice%+1)-8
        MOVE point%-80+(x3%*2),actamppos%(voice%+1) : PRINT amp3$
        ELSE LINE start%,714+shortamppos%(voice%)-((system%-1)*524)+8,point%-90+(x3%*2),714+shortamppos%(voice%)-((system%-1)*524)-8
        LINE start%,714+shortamppos%(voice%)-((system%-1)*524)-24,point%-90+(x3%*2),714+shortamppos%(voice%)-((system%-1)*524)-8
        MOVE point%-80+(x3%*2),714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp3$
        ENDIF
     ENDIF
     IF amp3% > amp2% THEN
        IF longscore$ = "y" THEN
        LINE start%,actamppos%(voice%+1)-8,point%-90+(x3%*2),actamppos%(voice%+1)+8
        LINE start%,actamppos%(voice%+1)-8,point%-90+(x3%*2),actamppos%(voice%+1)-24
        MOVE point%-80+(x3%*2),actamppos%(voice%+1) : PRINT amp3$
        ELSE LINE start%,714+shortamppos%(voice%)-((system%-1)*524)-8,point%-90+(x3%*2),714+shortamppos%(voice%)-((system%-1)*524)+8
        LINE start%,714+shortamppos%(voice%)-((system%-1)*524)-8,point%-90+(x3%*2),714+shortamppos%(voice%)-((system%-1)*524)-24
        MOVE point%-80+(x3%*2),714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp3$
        ENDIF
     ENDIF
  :
  WHEN 3 :
    ph1% = number% MOD 10^2
    point1% = ((dur%*ph1%/100)*factor)+hposn%+pointplus%
    ph2% = number% DIV 10^2
    point2% = ((dur%*ph2%/100)*factor)+hposn%+pointplus%
    :
    REM first phase
   IF amp2% < amp1% THEN
        IF longscore$ = "y" THEN
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)+8,point1%-35+x2%,actamppos%(voice%+1)-8
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)-24,point1%-35+x2%,actamppos%(voice%+1)-8
        MOVE point1%-25+x2%,actamppos%(voice%+1) : PRINT amp2$
        ELSE LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)+8,point1%-35+x2%,714+shortamppos%(voice%)-((system%-1)*524)-8
        LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)-24,point1%-35+x2%,714+shortamppos%(voice%)-((system%-1)*524)-8
        MOVE point1%-25+x2%,714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp2$
        ENDIF
    ENDIF
    IF amp2% > amp1% THEN
        IF longscore$ = "y" THEN
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)-8,point1%-35+x2%,actamppos%(voice%+1)+8
        LINE hposn%+x1%+y1%,actamppos%(voice%+1)-8,point1%-35+x2%,actamppos%(voice%+1)-24
        MOVE point1%-25+x2%,actamppos%(voice%+1) : PRINT amp2$
        ELSE LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)-8,point1%-35+x2%,714+shortamppos%(voice%)-((system%-1)*524)+8
        LINE hposn%+x1%+y1%,714+shortamppos%(voice%)-((system%-1)*524)-8,point1%-35+x2%,714+shortamppos%(voice%)-((system%-1)*524)-24
        MOVE point1%-25+x2%,714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp2$
        ENDIF
    ENDIF
    :
    REM second phase
    IF amp1% <> amp2% THEN start% = point1%-25+x2%+y2% ELSE start% = point1%
    IF amp3% < amp2% THEN
        IF longscore$ = "y" THEN
        LINE start%,actamppos%(voice%+1)+8,point2%-35+x3%,actamppos%(voice%+1)-8
        LINE start%,actamppos%(voice%+1)-24,point2%-35+x3%,actamppos%(voice%+1)-8
        MOVE point2%-25+x3%,actamppos%(voice%+1) : PRINT amp3$
        ELSE LINE start%,714+shortamppos%(voice%)-((system%-1)*524)+8,point2%-35+x3%,714+shortamppos%(voice%)-((system%-1)*524)-8
        LINE start%,714+shortamppos%(voice%)-((system%-1)*524)-24,point2%-35+x3%,714+shortamppos%(voice%)-((system%-1)*524)-8
        MOVE point2%-25+x3%,714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp3$
        ENDIF
     ENDIF
     IF amp3% > amp2% THEN
        IF longscore$ = "y" THEN
        LINE start%,actamppos%(voice%+1)-8,point2%-35+x3%,actamppos%(voice%+1)+8
        LINE start%,actamppos%(voice%+1)-8,point2%-35+x3%,actamppos%(voice%+1)-24
        MOVE point2%-25+x3%,actamppos%(voice%+1) : PRINT amp3$
        ELSE LINE start%,714+shortamppos%(voice%)-((system%-1)*524)-8,point2%-35+x3%,714+shortamppos%(voice%)-((system%-1)*524)+8
        LINE start%,714+shortamppos%(voice%)-((system%-1)*524)-8,point2%-35+x3%,714+shortamppos%(voice%)-((system%-1)*524)-24
        MOVE point2%-25+x3%,714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp3$
        ENDIF
     ENDIF
    :
    REM third phase
    IF amp2% <> amp3% THEN start% = point2%-25+x3%+y3% ELSE start% = point2%
    IF amp4% < amp3% THEN
        IF longscore$ = "y" THEN
        LINE start%,actamppos%(voice%+1)+8,point%-90+(x4%*2),actamppos%(voice%+1)-8
        LINE start%,actamppos%(voice%+1)-24,point%-90+(x4%*2),actamppos%(voice%+1)-8
        MOVE point%-80+(x4%*2),actamppos%(voice%+1) : PRINT amp4$
        ELSE LINE start%,714+shortamppos%(voice%)-((system%-1)*524)+8,point%-90+(x4%*2),714+shortamppos%(voice%)-((system%-1)*524)-8
        LINE start%,714+shortamppos%(voice%)-((system%-1)*524)-24,point%-90+(x4%*2),714+shortamppos%(voice%)-((system%-1)*524)-8
        MOVE point%-80+(x4%*2),714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp4$
        ENDIF
     ENDIF
     IF amp4% > amp3% THEN
        IF longscore$ = "y" THEN
        LINE start%,actamppos%(voice%+1)-8,point%-90+(x4%*2),actamppos%(voice%+1)+8
        LINE start%,actamppos%(voice%+1)-8,point%-90+(x4%*2),actamppos%(voice%+1)-24
        MOVE point%-80+(x4%*2),actamppos%(voice%+1) : PRINT amp4$
        ELSE LINE start%,714+shortamppos%(voice%)-((system%-1)*524)-8,point%-90+(x4%*2),714+shortamppos%(voice%)-((system%-1)*524)+8
        LINE start%,714+shortamppos%(voice%)-((system%-1)*524)-8,point%-90+(x4%*2),714+shortamppos%(voice%)-((system%-1)*524)-24
        MOVE point%-80+(x4%*2),714+shortamppos%(voice%)-((system%-1)*524) : PRINT amp4$
        ENDIF
     ENDIF
     :
 ENDCASE
 :
 ENDIF
:
:
 REM ledger lines
 IF staves$ = "y" THEN
 IF notehead$ = "big" THEN
  lend% = -12 : rend% = 44
 ENDIF
 IF notehead$ = "small" THEN
  lend% = 8 : rend% = 40
 ENDIF
 IF notehead$ = "vsmall" THEN
  lend% = 18 : rend% = 38
 ENDIF
 :
 IF longscore$ = "n" THEN
  IF value% = 858 THEN
   IF vposn% >= 954 THEN
    numledgers% = (vposn%-938)/16
    FOR ct% = 1 TO numledgers%
     LINE hposn%+lend%,954+((ct%-1)*16),hposn%+rend%,954+((ct%-1)*16)
    NEXT
   ENDIF
   IF vposn% = 858 THEN LINE hposn%+lend%,858,hposn%+rend%,858
  ENDIF
  IF value% = 586 THEN
   IF vposn% <= 714 THEN
    numledgers% = (730-vposn%)/16
    FOR ct% = 1 TO numledgers%
     LINE hposn%+lend%,714-((ct%-1)*16),hposn%+rend%,714-((ct%-1)*16)
    NEXT
   ENDIF
  ENDIF
  IF value% = 334 THEN
   IF vposn% >= 430 THEN
    numledgers% = (vposn%-414)/16
    FOR ct% = 1 TO numledgers%
     LINE hposn%+lend%,430+((ct%-1)*16),hposn%+rend%,430+((ct%-1)*16)
    NEXT
   ENDIF
   IF vposn% = 334 THEN LINE hposn%+lend%,334,hposn%+rend%,334
  ENDIF
  IF value% = 62 THEN
   IF vposn% <= 190 THEN
    numledgers% = (206-vposn%)/16
    FOR ct% = 1 TO numledgers%
     LINE hposn%+lend%,190-((ct%-1)*16),hposn%+rend%,190-((ct%-1)*16)
    NEXT
   ENDIF
  ENDIF
 ENDIF
 :
 IF longscore$ = "y" THEN
  CASE MID$(clefcombination$,ledgerkey%,1) OF
   WHEN "T" : num% = 320
   WHEN "P" : num% = 376
   WHEN "B" : num% = 224
   WHEN "D" : num% = 168
  ENDCASE
   IF vposn% - value% >= num% THEN
    numledgers% = ((vposn%-value%)-(num%-16))/16
    FOR ct% = 1 TO numledgers%
     LINE hposn% + lend%,value%+(num%-16)+(16*ct%),hposn%+rend%,value%+(num%-16)+(16*ct%)
    NEXT
   ENDIF
   IF vposn%-value% <= (num%-96) THEN
    numledgers% = ((num%-80)-(vposn%-value%))/16
    FOR ct% = 1 TO numledgers%
     LINE hposn%+lend%,(value%+(num%-80))-(16*ct%),hposn%+rend%,(value%+(num%-80))-(16*ct%)
    NEXT
   ENDIF
 ENDIF
 :
 ENDIF : REM applies to 'IF staves$ = "y" '
 :
 REM stems
  IF stems$ = "y" THEN
 IF longscore$ = "n" THEN
 IF notehead$ = "big" THEN
  LINE hposn%+30,vposn%,hposn%+30,938+shortbeamposn%(voice%)-(524*(system%-1))
 ENDIF
  LINE hposn%+32,vposn%,hposn%+32,938+shortbeamposn%(voice%)-(524*(system%-1))
 ENDIF
 :
 IF longscore$ = "y" THEN
  IF notehead$ = "big" THEN
   LINE hposn%+30,vposn%,hposn%+30,actbeamposn%(count%-startv%)
  ENDIF
   LINE hposn%+32,vposn%,hposn%+32,actbeamposn%(count%-startv%)
 ENDIF
 ENDIF
 :
 REM accidentals
  IF accidentals$ = "y" THEN
 acc% = (array%(startcell%,0,voice%)MOD100)DIV10
 IF notehead$ = "big" THEN
 CASE acc% OF
  WHEN 9 : REM sharp
   LINE hposn%-30,vposn%-24,hposn%-30,vposn%+24
   LINE hposn%-28,vposn%-24,hposn%-28,vposn%+24
   LINE hposn%-16,vposn%-24,hposn%-16,vposn%+24
   LINE hposn%-14,vposn%-24,hposn%-14,vposn%+24
   LINE hposn%-36,vposn%+4,hposn%-8,vposn%+12
   LINE hposn%-36,vposn%-12,hposn%-8,vposn%-4
  WHEN 8 : REM 3/8 sharp
   LINE hposn%-30,vposn%-24,hposn%-30,vposn%+24
   LINE hposn%-28,vposn%-24,hposn%-28,vposn%+24
   LINE hposn%-16,vposn%-24,hposn%-16,vposn%+24
   LINE hposn%-14,vposn%-24,hposn%-14,vposn%+24
   LINE hposn%-36,vposn%+4,hposn%-8,vposn%+12
   LINE hposn%-36,vposn%-12,hposn%-8,vposn%-4
   LINE hposn%-20,vposn%-20,hposn%-16,vposn%-28
   LINE hposn%-14,vposn%-28,hposn%-10,vposn%-20
   LINE hposn%-18,vposn%-20,hposn%-16,vposn%-28
    LINE hposn%-14,vposn%-28,hposn%-12,vposn%-20
   WHEN 1 : REM flat
    LINE hposn%-28,vposn%-12,hposn%-28,vposn%+28
    LINE hposn%-26,vposn%-12,hposn%-26,vposn%+28
    LINE hposn%-20,vposn%+8,hposn%-10,vposn%+8
    LINE hposn%-24,vposn%+4,hposn%-22,vposn%+4
    LINE hposn%-12,vposn%+4,hposn%-8,vposn%+4
    LINE hposn%-28,vposn%,hposn%-26,vposn%
    LINE hposn%-12,vposn%,hposn%-8,vposn%
    LINE hposn%-16,vposn%-4,hposn%-12,vposn%-4
    LINE hposn%-28,vposn%-8,hposn%-18,vposn%-8
   WHEN 2 : REM 3/8 flat
    LINE hposn%-28,vposn%-12,hposn%-28,vposn%+28
    LINE hposn%-26,vposn%-12,hposn%-26,vposn%+28
   LINE hposn%-20,vposn%+8,hposn%-10,vposn%+8
   LINE hposn%-24,vposn%+4,hposn%-22,vposn%+4
   LINE hposn%-12,vposn%+4,hposn%-8,vposn%+4
   LINE hposn%-28,vposn%,hposn%-26,vposn%
   LINE hposn%-12,vposn%,hposn%-8,vposn%
   LINE hposn%-16,vposn%-4,hposn%-12,vposn%-4
   LINE hposn%-28,vposn%-8,hposn%-18,vposn%-8
   LINE hposn%-32,vposn%+20,hposn%-28,vposn%+28
   LINE hposn%-26,vposn%+28,hposn%-22,vposn%+20
   LINE hposn%-30,vposn%+20,hposn%-28,vposn%+28
   LINE hposn%-26,vposn%+28,hposn%-24,vposn%+20
 WHEN 7 : REM quartersharp
  LINE hposn%-18,vposn%+24,hposn%-18,vposn%-24
  LINE hposn%-16,vposn%+24,hposn%-16,vposn%-24
  LINE hposn%-26,vposn%+4,hposn%-8,vposn%+12
  LINE hposn%-26,vposn%-12,hposn%-8,vposn%-4
 WHEN 3 : REM quarterflat
  LINE hposn%-12,vposn%-12,hposn%-12,vposn%+28
  LINE hposn%-10,vposn%-12,hposn%-10,vposn%+28
  LINE hposn%-28,vposn%+8,hposn%-18,vposn%+8
  LINE hposn%-30,vposn%+4,hposn%-26,vposn%+4
  LINE hposn%-16,vposn%+4,hposn%-14,vposn%+4
  LINE hposn%-30,vposn%,hposn%-26,vposn%
  LINE hposn%-26,vposn%-4,hposn%-22,vposn%-4
  LINE hposn%-20,vposn%-8,hposn%-10,vposn%-8
 WHEN 5 : REM natural
  LINE hposn%-30,vposn%+24,hposn%-30,vposn%-8
  LINE hposn%-28,vposn%+24,hposn%-28,vposn%-8
  LINE hposn%-12,vposn%+8,hposn%-12,vposn%-24
  LINE hposn%-10,vposn%+8,hposn%-10,vposn%-24
  LINE hposn%-30,vposn%+4,hposn%-24,vposn%+4
  LINE hposn%-22,vposn%+8,hposn%-18,vposn%+8
  LINE hposn%-16,vposn%+12,hposn%-10,vposn%+12
  LINE hposn%-30,vposn%-12,hposn%-24,vposn%-12
  LINE hposn%-22,vposn%-8,hposn%-18,vposn%-8
  LINE hposn%-16,vposn%-4,hposn%-10,vposn%-4
 WHEN 4 : REM 1/8 flat
  LINE hposn%-30,vposn%+24,hposn%-30,vposn%-8
  LINE hposn%-28,vposn%+24,hposn%-28,vposn%-8
  LINE hposn%-12,vposn%+8,hposn%-12,vposn%-24
  LINE hposn%-10,vposn%+8,hposn%-10,vposn%-24
  LINE hposn%-30,vposn%+4,hposn%-24,vposn%+4
  LINE hposn%-22,vposn%+8,hposn%-18,vposn%+8
  LINE hposn%-16,vposn%+12,hposn%-10,vposn%+12
  LINE hposn%-30,vposn%-12,hposn%-24,vposn%-12
  LINE hposn%-22,vposn%-8,hposn%-18,vposn%-8
  LINE hposn%-16,vposn%-4,hposn%-10,vposn%-4
  LINE hposn%-16,vposn%-20,hposn%-12,vposn%-28
  LINE hposn%-10,vposn%-28,hposn%-6,vposn%-20
  LINE hposn%-14,vposn%-20,hposn%-12,vposn%-28
  LINE hposn%-10,vposn%-28,hposn%-8,vposn%-20
 WHEN 6 : REM 1/8 sharp
  LINE hposn%-30,vposn%+24,hposn%-30,vposn%-8
  LINE hposn%-28,vposn%+24,hposn%-28,vposn%-8
  LINE hposn%-12,vposn%+8,hposn%-12,vposn%-24
  LINE hposn%-10,vposn%+8,hposn%-10,vposn%-24
  LINE hposn%-30,vposn%+4,hposn%-24,vposn%+4
  LINE hposn%-22,vposn%+8,hposn%-18,vposn%+8
  LINE hposn%-16,vposn%+12,hposn%-10,vposn%+12
  LINE hposn%-30,vposn%-12,hposn%-24,vposn%-12
  LINE hposn%-22,vposn%-8,hposn%-18,vposn%-8
  LINE hposn%-16,vposn%-4,hposn%-10,vposn%-4
  LINE hposn%-34,vposn%+20,hposn%-30,vposn%+28
  LINE hposn%-32,vposn%+20,hposn%-30,vposn%+28
  LINE hposn%-26,vposn%+20,hposn%-28,vposn%+28
  LINE hposn%-24,vposn%+20,hposn%-28,vposn%+28
 ENDCASE
 ENDIF
 IF notehead$ = "vsmall" THEN
  CASE acc% OF
   WHEN 5 : REM natural
    LINE hposn%+12,vposn%+24,hposn%+12,vposn%-4
    LINE hposn%+20,vposn%+4,hposn%+20,vposn%-24
    LINE hposn%+12,vposn%+4,hposn%+20,vposn%+8
    LINE hposn%+12,vposn%-8,hposn%+20,vposn%-4
  WHEN 6 : REM 1/8 sharp
    LINE hposn%+12,vposn%+24,hposn%+12,vposn%-4
    LINE hposn%+20,vposn%+4,hposn%+20,vposn%-24
    LINE hposn%+12,vposn%+4,hposn%+20,vposn%+8
    LINE hposn%+12,vposn%-8,hposn%+20,vposn%-4
    LINE hposn%+10,vposn%+20,hposn%+12,vposn%+28
    LINE hposn%+14,vposn%+20,hposn%+12,vposn%+28
    LINE hposn%+8,vposn%+20,hposn%+12,vposn%+28
    LINE hposn%+16,vposn%+20,hposn%+12,vposn%+28
   WHEN 9 : REM sharp
    LINE hposn%+12,vposn%+24,hposn%+12,vposn%-24
    LINE hposn%+18,vposn%+24,hposn%+18,vposn%-24
    LINE hposn%+10,vposn%+4,hposn%+20,vposn%+8
    LINE hposn%+10,vposn%-8,hposn%+20,vposn%-4
   WHEN 8 : REM 3/8 sharp
    LINE hposn%+12,vposn%+24,hposn%+12,vposn%-24
    LINE hposn%+18,vposn%+24,hposn%+18,vposn%-24
    LINE hposn%+10,vposn%+4,hposn%+20,vposn%+8
    LINE hposn%+10,vposn%-8,hposn%+20,vposn%-4
    LINE hposn%+14,vposn%-20,hposn%+18,vposn%-28
    LINE hposn%+16,vposn%-20,hposn%+18,vposn%-28
    LINE hposn%+20,vposn%-20,hposn%+18,vposn%-28
    LINE hposn%+22,vposn%-20,hposn%+18,vposn%-28
   WHEN 4 : REM 1/8 flat
    LINE hposn%+12,vposn%+24,hposn%+12,vposn%-4
    LINE hposn%+20,vposn%+4,hposn%+20,vposn%-24
    LINE hposn%+12,vposn%+4,hposn%+20,vposn%+8
    LINE hposn%+12,vposn%-8,hposn%+20,vposn%-4
    LINE hposn%+16,vposn%-20,hposn%+20,vposn%-28
    LINE hposn%+18,vposn%-20,hposn%+20,vposn%-28
    LINE hposn%+22,vposn%-20,hposn%+20,vposn%-28
    LINE hposn%+24,vposn%-20,hposn%+20,vposn%-28
   WHEN 7 : REM quartersharp
    LINE hposn%+18,vposn%+24,hposn%+18,vposn%-24
    LINE hposn%+16,vposn%+4,hposn%+20,vposn%+8
    LINE hposn%+16,vposn%-8,hposn%+20,vposn%-4
   WHEN 2 : REM 3/8 flat
    LINE hposn%+12,vposn%+28,hposn%+12,vposn%-12
    LINE hposn%+16,vposn%+8,hposn%+18,vposn%+8
    LINE hposn%+14,vposn%+4,hposn%+14,vposn%+4
    LINE hposn%+20,vposn%+4,hposn%+20,vposn%+4
    LINE hposn%+20,vposn%,hposn%+20,vposn%
    LINE hposn%+18,vposn%-4,hposn%+18,vposn%-4
    LINE hposn%+12,vposn%-8,hposn%+16,vposn%-8
    LINE hposn%+8,vposn%+20,hposn%+12,vposn%+28
    LINE hposn%+10,vposn%+20,hposn%+12,vposn%+28
    LINE hposn%+14,vposn%+20,hposn%+12,vposn%+28
    LINE hposn%+16,vposn%+20,hposn%+12,vposn%+28
   WHEN 1 : REM flat
    LINE hposn%+12,vposn%+28,hposn%+12,vposn%-12
    LINE hposn%+16,vposn%+8,hposn%+18,vposn%+8
    LINE hposn%+14,vposn%+4,hposn%+14,vposn%+4
    LINE hposn%+20,vposn%+4,hposn%+20,vposn%+4
    LINE hposn%+20,vposn%,hposn%+20,vposn%
    LINE hposn%+18,vposn%-4,hposn%+18,vposn%-4
    LINE hposn%+12,vposn%-8,hposn%+16,vposn%-8
   WHEN 3 : REM quarterflat
    LINE hposn%+20,vposn%+28,hposn%+20,vposn%-12
    LINE hposn%+14,vposn%+8,hposn%+16,vposn%+8
    LINE hposn%+12,vposn%+4,hposn%+12,vposn%+4
    LINE hposn%+18,vposn%+4,hposn%+18,vposn%+4
    LINE hposn%+12,vposn%,hposn%+12,vposn%
    LINE hposn%+14,vposn%-4,hposn%+14,vposn%-4
    LINE hposn%+16,vposn%-8,hposn%+20,vposn%-8
  ENDCASE
 inf% = (array%(startcell%,2,voice%)MOD100)-50
 IF inf% < 0 THEN
    MOVE hposn%-125,vposn%-30 : PRINT inf%;"c"
   ENDIF
 IF inf% > 0 THEN
    MOVE hposn%-16,vposn%+45 : PRINT "+";inf%;"c"
    ENDIF
 ENDIF
 :
 IF notehead$ = "small" THEN
  CASE acc% OF
   WHEN 1 : REM flat
    LINE hposn%-2,vposn%+28,hposn%-2,vposn%-12
    LINE hposn%+4,vposn%+8,hposn%+8,vposn%+8
    LINE hposn%,vposn%+4,hposn%+2,vposn%+4
    LINE hposn%+8,vposn%+4,hposn%+10,vposn%+4
    LINE hposn%+8,vposn%,hposn%+10,vposn%
    LINE hposn%+4,vposn%-4,hposn%+6,vposn%-4
    LINE hposn%-2,vposn%-8,hposn%+2,vposn%-8
   WHEN 2 : REM 3/8 flat
    LINE hposn%-2,vposn%+28,hposn%-2,vposn%-12
    LINE hposn%+4,vposn%+8,hposn%+8,vposn%+8
    LINE hposn%,vposn%+4,hposn%+2,vposn%+4
    LINE hposn%+8,vposn%+4,hposn%+10,vposn%+4
    LINE hposn%+8,vposn%,hposn%+10,vposn%
    LINE hposn%+4,vposn%-4,hposn%+6,vposn%-4
    LINE hposn%-2,vposn%-8,hposn%+2,vposn%-8
    LINE hposn%-6,vposn%+20,hposn%-2,vposn%+28
    LINE hposn%-4,vposn%+20,hposn%-2,vposn%+28
    LINE hposn%,vposn%+20,hposn%-2,vposn%+28
    LINE hposn%+2,vposn%+20,hposn%-2,vposn%+28
   WHEN 3 : REM quarterflat
    LINE hposn%+10,vposn%+28,hposn%+10,vposn%-12
    LINE hposn%,vposn%+8,hposn%+4,vposn%+8
    LINE hposn%-2,vposn%+4,hposn%,vposn%+4
    LINE hposn%+6,vposn%+4,hposn%+8,vposn%+4
    LINE hposn%-2,vposn%,hposn%,vposn%
    LINE hposn%+2,vposn%-4,hposn%+4,vposn%-4
    LINE hposn%+6,vposn%-8,hposn%+10,vposn%-8
   WHEN 5 : REM natural
    LINE hposn%,vposn%+24,hposn%,vposn%-4
    LINE hposn%+10,vposn%+4,hposn%+10,vposn%-24
    LINE hposn%,vposn%+4,hposn%+10,vposn%+8
    LINE hposn%,vposn%-8,hposn%+10,vposn%-4
   WHEN 6 : REM 1/8 sharp
    LINE hposn%,vposn%+24,hposn%,vposn%-4
    LINE hposn%+10,vposn%+4,hposn%+10,vposn%-24
    LINE hposn%,vposn%+4,hposn%+10,vposn%+8
    LINE hposn%,vposn%-8,hposn%+10,vposn%-4
    LINE hposn%-4,vposn%+20,hposn%,vposn%+28
    LINE hposn%-2,vposn%+20,hposn%,vposn%+28
    LINE hposn%+2,vposn%+20,hposn%,vposn%+28
    LINE hposn%+4,vposn%+20,hposn%,vposn%+28
   WHEN 7 : REM quartersharp
    LINE hposn%+6,vposn%+24,hposn%+6,vposn%-24
    LINE hposn%+2,vposn%+4,hposn%+10,vposn%+8
    LINE hposn%+2,vposn%-8,hposn%+10,vposn%-4
   WHEN 4 : REM 1/8 flat
    LINE hposn%,vposn%+24,hposn%,vposn%-4
    LINE hposn%+10,vposn%+4,hposn%+10,vposn%-24
    LINE hposn%,vposn%+4,hposn%+10,vposn%+8
    LINE hposn%,vposn%-8,hposn%+10,vposn%-4
    LINE hposn%+6,vposn%-20,hposn%+10,vposn%-28
    LINE hposn%+8,vposn%-20,hposn%+10,vposn%-28
    LINE hposn%+12,vposn%-20,hposn%+10,vposn%-28
    LINE hposn%+14,vposn%-20,hposn%+10,vposn%-28
   WHEN 9 : REM sharp
    LINE hposn%-2,vposn%+24,hposn%-2,vposn%-24
    LINE hposn%+6,vposn%+24,hposn%+6,vposn%-24
    LINE hposn%-6,vposn%+4,hposn%+10,vposn%+8
    LINE hposn%-6,vposn%-8,hposn%+10,vposn%-4
   WHEN 8 : REM 3/8 sharp
    LINE hposn%-2,vposn%+24,hposn%-2,vposn%-24
    LINE hposn%+6,vposn%+24,hposn%+6,vposn%-24
    LINE hposn%-6,vposn%+4,hposn%+10,vposn%+8
    LINE hposn%-6,vposn%-8,hposn%+10,vposn%-4
    LINE hposn%+2,vposn%-20,hposn%+6,vposn%-28
    LINE hposn%+4,vposn%-20,hposn%+6,vposn%-28
    LINE hposn%+8,vposn%-20,hposn%+6,vposn%-28
    LINE hposn%+10,vposn%-20,hposn%+6,vposn%-28
   ENDCASE
 :
  ENDIF
 ENDIF
 startcell% += 1
 IF longscore$ = "n" THEN div% = 2 ELSE div% = 1
 :
 UNTIL (array%(startcell%,0,voice%) DIV10^6) >= ((numbars%/div%)+firstbar%) OR array%(startcell%,0,voice%) = 0
 ENDIF
 :
 IF stems$ = "y" THEN PROCrhythmdisplay
 :
 IF longscore$ = "y" THEN ledgerkey% += EVAL(MID$(stavecombination$,count%-startv%+1,1))
 :
 NEXT
 :
 NEXT
 :
 VDU 4 : OFF : box$ = "n" : biga% = 10^5 : bigb% = 0 : bigc% = 0 : bigd% = 10^5
 IF printing$ = "n" AND preplaydisplay$ = "n" THEN PROCpostdisplay
 ENDPROC
 :
 REM*************************************************
 :
 DEF PROCroundgliss
 :
 IF thirdphase$ = "n" THEN gl1% = 50-gl% ELSE gl1% = 10-gl%
 gl% = gl1%*1.1665 : gl% = (gl%DIV4)*4
   IF gl% = 0 THEN
    IF gl1% > 0 THEN gl% = 4 ELSE gl% = -4
   ENDIF
   IF gl% < 0 THEN g% = gl%*-1 ELSE g% = gl%
   rem = g%/8
   IF (rem*10)MOD10 <> 0 THEN
    IF gl% > 0 THEN gl% += 4 ELSE gl% -= 4
   ENDIF
 :
 ENDPROC
 :
 REM**************************************************
 :
 DEF PROCpostdisplay
 :
 distort$ = "OFF"
 REM in case of Escaping from a distort routine before switching it off
 :
 OFF
 CASE GET$ OF
 :
 WHEN "i" :
 PROCwindow(20,69,60,55)
 CLS : PRINT'" Copy-extract or move-extract? (C/M) "
   CASE GET$ OF
    WHEN "C","c" : copymove$ = "EC"
    OTHERWISE copymove$ = "EM"
   ENDCASE
   savevoice$ = "N"
 PROCcopy2
 :
 WHEN "{" : quickcopy$ = "y" : PROCdisplay
 WHEN "}" : quickcopy$ = "n" : PROCdisplay
 WHEN "�" :
  PROCwindow(20,69,60,55) : CLS
  INPUT'" Display from which voice "startv%
  PROCdisplay
 :
 WHEN "@" :
  IF easiermenus$ = "y" THEN easiermenus$ = "n" ELSE easiermenus$ = "y"
  PROCdisplay
 WHEN "`" :
  distort$ = "ON" : distortpara$ = "attacks" : ON
  PROCwindow(20,69,60,55) : CLS : OFF :
  incre$ = INKEY$(50)
  IF incre$ = "`" THEN
   distortpara$ = "pitches"
  ENDIF
  PROCcopy
 :
 WHEN "+" :
  numvoices% = numparts%
  FOR count% = 1 TO numvoices%
     displayvoices%(count%) = 1 + count% - 1
     holddisplay%(count%) = 1 + count% - 1
    NEXT
  holdnum% = numvoices%
  PROCdisplay
   :
   WHEN "!" : copydownwards% = 1 :
    IF addten$ = "y" THEN copydownwards% +=10
    IF addten$ = "twenty" THEN copydownwards% += 20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
     WHEN ")" : downby% = 10
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
  WHEN """" : copydownwards% = 2 :
   IF addten$ = "y" THEN copydownwards% +=10
   IF addten$ = "twenty" THEN copydownwards% +=20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
  WHEN "�" : copydownwards% = 3 :
   IF addten$ = "y" THEN copydownwards% +=10
   IF addten$ = "twenty" THEN copydownwards% +=20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
  WHEN "$" : copydownwards% = 4 :
   IF addten$ = "y" THEN copydownwards% +=10
   IF addten$ = "twenty" THEN copydownwards% +=20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
  WHEN "%" : copydownwards% = 5 :
   IF addten$ = "y" THEN copydownwards% +=10
   IF addten$ = "twenty" THEN copydownwards% +=20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
  WHEN "^" : copydownwards% = 6 :
   IF addten$ = "y" THEN copydownwards% +=10
   IF addten$ = "twenty" THEN copydownwards% +=20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
  WHEN "&" : copydownwards% = 7 :
   IF addten$ = "y" THEN copydownwards% +=10
   IF addten$ = "twenty" THEN copydownwards% +=20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
  WHEN "*" : copydownwards% = 8 :
   IF addten$ = "y" THEN copydownwards% +=10
   IF addten$ = "twenty" THEN copydownwards% +=20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
  WHEN "(" : copydownwards% = 9 :
   IF addten$ = "y" THEN copydownwards% +=10
   IF addten$ = "twenty" THEN copydownwards% +=20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
  WHEN ")" : copydownwards% = 10 :
   IF addten$ = "y" THEN copydownwards% +=10
   IF addten$ = "twenty" THEN copydownwards% +=20
   incre$ = INKEY$(downwardsspeed%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : downby% = 1
     WHEN """" : downby% = 2
     WHEN "�" : downby% = 3
     WHEN "$" : downby% = 4
     WHEN "%" : downby% = 5
     WHEN "^" : downby% = 6
     WHEN "&" : downby% = 7
     WHEN "*" : downby% = 8
     WHEN "(" : downby% = 9
    ENDCASE
   ELSE downby% = 1
   ENDIF
   PROCcopydownwards
   :
  WHEN "c" : PROCincrementcalc
  WHEN "k" : ON : PROCkeyboardshortcuts
  WHEN "I" : copymove$ = "C" : savevoice$ = "N" : PROCwindow(20,69,60,55) : PROCimportvoice
  WHEN "0",")" : PROCseriesattacks
  WHEN "a" : PROCfunctionprelude
  WHEN "m" : ON : PROCawait
  WHEN "n" : ON : rerun$ = "n" : PROCrandomnumber
  WHEN "N" : ON : rerun$ = "y" : PROCrandomnumber
  WHEN "o" : ON : PROCdisplaysubmenu
  WHEN "O" : deleteone$ = "top" : PROCdelete
  WHEN "K" : deleteone$ = "middle" : PROCdelete
  WHEN "M" : deleteone$ = "bottom" : PROCdelete
  WHEN "r" : play$ = "replay" : PROCplay
  WHEN "u" : ON : PROCseriesdurations
  WHEN "G", "g" : ON : numdurations% = 111 : PROCdurationsbetween
  WHEN "\" : ON : PROCshortmove
  WHEN "|" : ON : PROCshortmoveone
  WHEN "y" : ON : PROCseriespitches
  WHEN "Y" :
   IF addpitches$ = "y" THEN
   PROCwindow(20,69,60,55)
   ON
   CLS
   PROCinsertpitches
   ELSE
    voix% = 1 : son% = 5 : PROCedit
   ENDIF
  WHEN "l" : ON : PROCseriesamplitudes
  WHEN "J","j" : ON : PROCseriesenvelopes
  WHEN "h" : ON : PROCwindow(20,57,74,55)
  PRINT'" Have you previously allocated at least 260K memory "
  PRINT " for system sprites and double-clicked !Paint "
  CASE GET$ OF
   WHEN "N","n" : PROCdisplay
   WHEN "Y","y" :
    printing$ = "y" : printno% += 1 : PROCdisplay
 MOVE 0,0
 MOVE 1800,1223
 *SGet mysprite
 OSCLI "SSave SDFS::RISCOSpi.$.CAC.Printing.print"+STR$(printno%)
 printing$ = "n" : PROCdisplay
  ENDCASE
  WHEN "v" : startv% += updisplay%
   incre$ = INKEY$(vertscroll%)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "V","v" :
      IF screenmovesby% = 10 THEN startv%+=9 ELSE startv%+=2
     WHEN "0" : startv%+=49
     OTHERWISE startv% += EVAL(incre$)-1
    ENDCASE
   ENDIF
   IF startv% > (numvoices%-lastcount%) THEN startv%= numvoices%-lastcount%
   PROCdisplay
   WHEN "6" :
    startv% -= updisplay%
    decre$ = INKEY$(vertscroll%)
    IF decre$ <> "" THEN
     CASE decre$ OF
      WHEN "6" :
       IF screenmovesby% = 10 THEN startv%-=9 ELSE startv%-=2
      WHEN "0" : startv%-=49
      OTHERWISE startv% -= EVAL(decre$)-1
     ENDCASE
    ENDIF
   IF startv% < 1 THEN startv% = 1
    PROCdisplay
   WHEN "." : startbar% += 1
    incre$ = INKEY$(horizscroll%)
    IF incre$ <> "" THEN
     IF incre$ = ">" OR incre$ = "." THEN startbar% += numbars%-1 ELSE startbar% += EVAL(incre$)-1
    ENDIF
 requestedend% = startbar% + numbars%
 IF requestedend% > nobars% THEN startbar% -= (requestedend%-nobars%)
    PROCdisplay
   WHEN "," : startbar% -= 1
    decre$ = INKEY$(horizscroll%)
    IF decre$ <> "" THEN
     IF decre$ = "<" OR decre$ = "," THEN startbar% -= numbars%-1 ELSE startbar% -= EVAL(decre$)-1
    ENDIF
    IF startbar%<1 THEN startbar% = 1
    PROCdisplay
  WHEN "V" : ON : PROCwindow(20,69,60,55)
   IF namestaves$ = "nameone" THEN PROCnamestaves ELSE PROCdeletenames
   PROCdisplay
  WHEN "b" :
   PROCwindow(20,57,34,55) : ON : INPUT'" Go to bar "startbar%
   requestedend% = startbar% + numbars%
   IF requestedend% > nobars% THEN startbar% -= (requestedend% - nobars%)
   PROCdisplay
  WHEN "s" :
   CASE sequalssection$ OF
    WHEN "y" :
     PROCwindow(20,17,38,15) : ON : INPUT'" Go to section "section$
     count% = 0 : found$ = "n"
     REPEAT
     count% += 1
     IF remarks$(count%,0) = "SECTION "+section$ OR remarks$(count%,1) = "SECTION "+section$ THEN
     startbar% = count% : found$ = "y"
     ENDIF
     UNTIL found$ = "y" OR count% > nobars%
     PROCdisplay
    WHEN "n" :
     copysuccessively$ = "y" : PROCcopygroupofnotes
    ENDCASE : REM sequalussection
  WHEN "d" : PROCwindow(20,58,45,55) : ON
   INPUT'" Display how many bars? "numbars%
 requestedend% = startbar% + numbars%
 IF requestedend% > nobars% THEN startbar% -= (requestedend%-nobars%)
 IF startbar% < 1 THEN
  startbar% = 1 : numbars% = nobars%-1
 ENDIF
   PROCdisplay
  WHEN "=" : numbars% = numbars%*2
 requestedend% = startbar% + numbars%
 IF requestedend% > nobars% THEN startbar% -= (requestedend%-nobars%)
 IF startbar% < 1 THEN
  startbar% = 1 : numbars% = nobars%-1
 ENDIF
 PROCdisplay
  WHEN "q" :
    PROCquickdisplay
  WHEN "w" :
    CASE toggle$ OF
     WHEN "prevquick" : toggle$ = "orig"
     WHEN "quick" : toggle$ = "prevquick"
     WHEN "orig" : toggle$ = "quick"
    ENDCASE
     CASE toggle$ OF
      WHEN "prevquick" :
      numvoices% = prequicknum%
      FOR count% = 1 TO numvoices%
       displayvoices%(count%) = prequickdisplay%(count%)
      NEXT
      startv% = prequickstart%
      WHEN "quick" :
      numvoices% = quicknum%
      FOR count% = 1 TO numvoices%
       displayvoices%(count%) = quickdisplay%(count%)
      NEXT
      startv% = quickstart%
      WHEN "orig" :
       numvoices% = holdnum%
      FOR count% = 1 TO numvoices%
       displayvoices%(count%) = holddisplay%(count%)
      NEXT
      startv% = holdstart%
     ENDCASE
     PROCdisplay


  WHEN "p" :
   play$ = "playscreen" : startingbar% = startbar% : startbeat% = 0
   endbar% = nobars% : nvoices% = quickplay%
   FOR count% = 1 TO quickplay%
     playvoices%(count%) = displayvoices%(startv%+count%-1)
   NEXT
   PROCplay

WHEN ";" :
   play$ = "playscreen" : startingbar% = startbar% : startbeat% = 0
   endbar% = nobars% : nvoices% = 1
     playvoices%(1) = displayvoices%(startv%+1)

   PROCplay

WHEN "/" :
   play$ = "playscreen" : startingbar% = startbar% : startbeat% = 0
   endbar% = nobars% : nvoices% = 1
     playvoices%(1) = displayvoices%(startv%+2)

   PROCplay


 WHEN "P" :
   play$ = "playscreen" : startingbar% = startbar% : startbeat% = 0
   endbar% = startbar%+numbars%-1 : nvoices% = quickplay%
   FOR count% = 1 TO quickplay%
     playvoices%(count%) = displayvoices%(startv%+count%-1)
   NEXT
   PROCplay

WHEN ":" :
   play$ = "playscreen" : startingbar% = startbar% : startbeat% = 0
   endbar% = startbar%+numbars%-1 : nvoices% = 1
     playvoices%(1) = displayvoices%(startv%+1)
   PROCplay

WHEN "?" :
   play$ = "playscreen" : startingbar% = startbar% : startbeat% = 0
   endbar% = startbar%+numbars%-1 : nvoices% = 1
     playvoices%(1) = displayvoices%(startv%+2)
   PROCplay

  WHEN "z" : PROCcopyonenote
  WHEN "x" : PROCcopygroupofnotes
  WHEN "-" :
  IF numbars% > 1 THEN numbars% = numbars%/2
  PROCdisplay
  WHEN "t" : funcinput$ = "durat" : PROCdisplay
  WHEN "e" : funcinput$ = "points" : PROCdisplay
  WHEN "f" : funcinput$ = "displayed" : PROCdisplay
  :
  WHEN "1" :
   IF setalong$ = "y" THEN along% = 0 : PROCpostdisplay
   IF setalong$ = "n" THEN numvoices% = 1 : numvoicesgiven$ = "y" : PROCquickdisplay
   IF setalong$ = "playnovoices" THEN quickplay% = 1 : PROCdisplay
  WHEN "2" :
   IF setalong$ = "y" THEN along% = 1 : PROCpostdisplay
   IF setalong$ = "n" THEN numvoices% = 2 : numvoicesgiven$ = "y" : PROCquickdisplay
   IF setalong$ = "playnovoices" THEN quickplay% = 2 : PROCdisplay
  WHEN "3" :
   IF setalong$ = "y" THEN along% = 2 : PROCpostdisplay
   IF setalong$ = "n" THEN numvoices% = 3 : numvoicesgiven$ = "y" : PROCquickdisplay
   IF setalong$ = "playnovoices" THEN quickplay% = 3 : PROCdisplay
  WHEN "4" :
   IF setalong$ = "y" THEN along% = 3 : PROCpostdisplay
   IF setalong$ = "n" THEN numvoices% = 4 : numvoicesgiven$ = "y" : PROCquickdisplay
   IF setalong$ = "playnovoices" THEN quickplay% = 4 : PROCdisplay
  WHEN "5" :
   IF setalong$ = "y" THEN along% = 4 : PROCpostdisplay
   IF setalong$ = "n" THEN numvoices% = 5 : numvoicesgiven$ = "y" : PROCquickdisplay
   IF setalong$ = "playnovoices" THEN quickplay% = 5 : PROCdisplay
  WHEN "7" :
   IF setalong$ = "y" THEN along% = 6 : PROCpostdisplay
   IF setalong$ = "n" THEN numvoices% = 7 : numvoicesgiven$ = "y" : PROCquickdisplay
   IF setalong$ = "playnovoices" THEN quickplay% = 7 : PROCdisplay
  WHEN "8" :
   IF setalong$ = "y" THEN along% = 7 : PROCpostdisplay
   IF setalong$ = "n" THEN numvoices% = 8 : numvoicesgiven$ = "y" : PROCquickdisplay
   IF setalong$ = "playnovoices" THEN quickplay% = 8 : PROCdisplay
  WHEN "9" :
   IF setalong$ = "y" THEN along% = 8 : PROCpostdisplay
   IF setalong$ = "n" THEN numvoices% = 9 : numvoicesgiven$ = "y" : PROCquickdisplay
   IF setalong$ = "playnovoices" THEN
    PROCwindow(20,69,60,55)
    PRINT'" The maximum number of voices "
    PRINT " that can be played is 8 "
    PRINT'" (press a key to continue) "
    CASE GET$ OF
     OTHERWSE PROCdisplay
    ENDCASE
   ENDIF
  WHEN "]" :
IF squarebracket$ = "remarks" THEN
   count% = startbar%-1
   REPEAT
    count%+=1
    IF remarks$(count%,0) <> "" THEN itt% = count%
   UNTIL remarks$(count%,0) <> ""
   remarks$(itt%+1,0) = remarks$(itt%,0)
   remarks$(itt%,0) = ""
ELSE
 addten$ = "y"
ENDIF
PROCdisplay
 WHEN "}" :
   count% = startbar%-1
   REPEAT
    count%+=1
    IF remarks$(count%,0) <> "" THEN itt% = count%
   UNTIL remarks$(count%,0) <> ""
   remarks$(itt%+10,0) = remarks$(itt%,0)
   remarks$(itt%,0) = ""
   PROCdisplay
 WHEN "[" :
  IF squarebracket$ = "remarks" THEN
   count% = startbar%-1
   REPEAT
    count%+=1
    IF remarks$(count%,0) <> "" THEN itt% = count%
   UNTIL remarks$(count%,0) <> ""
   remarks$(itt%-1,0) = remarks$(itt%,0)
   remarks$(itt%,0) = ""
  ELSE
   addten$ = "n"
  ENDIF
  PROCdisplay
 WHEN "{" :
   count% = startbar%-1
   REPEAT
    count%+=1
    IF remarks$(count%,0) <> "" THEN itt% = count%
   UNTIL remarks$(count%,0) <> ""
   remarks$(itt%-10,0) = remarks$(itt%,0)
   remarks$(itt%,0) = ""
   PROCdisplay
 WHEN "#" :
 IF squarebracket$ = "remarks" THEN
   count% = startbar%-1
   REPEAT
    count%+=1
    IF remarks$(count%,1) <> "" THEN itt% = count%
   UNTIL remarks$(count%,1) <> ""
   remarks$(itt%+1,1) = remarks$(itt%,1)
   remarks$(itt%,1) = ""
  ENDIF
   PROCdisplay
 WHEN "'" :
  IF squarebracket$ = "remarks" THEN
   count% = startbar%-1
   REPEAT
    count%+=1
    IF remarks$(count%,1) <> "" THEN itt% = count%
   UNTIL remarks$(count%,1) <> ""
   remarks$(itt%-1,1) = remarks$(itt%,1)
   remarks$(itt%,1) = ""
  ELSE
   addten$ = "twenty"
  ENDIF
   PROCdisplay
 WHEN "L" : slavemethod$ = "random" : quickslave$ = "y" : PROCslave
  WHEN "Q" : voix% = 1 : son% = 0 : PROCedit
 WHEN "W" : voix% = 1 : son% = 1 : PROCedit
 WHEN "E" : voix% = 1 : son% = 2 : PROCedit
 WHEN "R" : voix% = 1 : son% = 3 : PROCedit
 WHEN "T" : voix% = 1 : son% = 4 : PROCedit
 WHEN "A" : voix% = 2 : son% = 0 : PROCedit
 WHEN "S" : voix% = 2 : son% = 1 : PROCedit
 WHEN "D" : voix% = 2 : son% = 2 : PROCedit
 WHEN "F" : voix% = 2 : son% = 3 : PROCedit
 WHEN "G" : voix% = 2 : son% = 4 : PROCedit
 WHEN "H" : voix% = 2 : son% = 5 : PROCedit
 WHEN "Z" : voix% = 3 : son% = 0 : PROCedit
 WHEN "X" : voix% = 3 : son% = 1 : PROCedit
 WHEN "C" : voix% = 3 : son% = 2 : PROCedit
 WHEN "V" : voix% = 3 : son% = 3 : PROCedit
 WHEN "B" : voix% = 3 : son% = 4 : PROCedit
 WHEN "N" : voix% = 3 : son% = 5 : PROCedit

WHEN ">" :

 voice% = displayvoices%(voix%+(startv%-1))-1

 CASE editwhat$ OF
  WHEN "1stenvelope" :
   array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) + 100000
  WHEN "2ndenvelope" :
   array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) + 10000000

  WHEN "1stamplitude" :
   array%(holdstartcell%(voice%)+son%,1,voice%) = array%(holdstartcell%(voice%)+son%,1,voice%) + 1
   IF array%(holdstartcell%(voice%)+son%,1,voice%)MOD10 = 9 THEN
    array%(holdstartcell%(voice%)+son%,1,voice%) = array%(holdstartcell%(voice%)+son%,1,voice%) - 9
   ENDIF


  WHEN "2ndamplitude" :
   array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) + 100

   IF (array%(holdstartcell%(voice%)+son%,2,voice%)DIV10^2)MOD10 = 9 THEN
    array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) - 900
   ENDIF



  WHEN "3rdamplitude" :
   array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) + 1000

   IF (array%(holdstartcell%(voice%)+son%,2,voice%)DIV10^3)MOD10 = 9 THEN
    array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) - 9000
   ENDIF


  WHEN "4thamplitude" :
   array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) + 10000
   IF (array%(holdstartcell%(voice%)+son%,2,voice%)DIV10^4)MOD10 = 9 THEN
    array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) - 90000
   ENDIF


WHEN "movetwo" :

   array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) + 60000
   IF  (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3 > 900 THEN
    number% = (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3
    array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) - (number%*1000)
    array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) + 1000000
   ENDIF

   array%(holdstartcell%(voice%)+son%+1,0,voice%) = array%(holdstartcell%(voice%)+son%+1,0,voice%) + 60000
   IF  (array%(holdstartcell%(voice%)+son%+1,0,voice%)DIV10^3)MOD10^3 > 900 THEN
    number% = (array%(holdstartcell%(voice%)+son%+1,0,voice%)DIV10^3)MOD10^3
    array%(holdstartcell%(voice%)+son%+1,0,voice%) = array%(holdstartcell%(voice%)+son%+1,0,voice%) - (number%*1000)
    array%(holdstartcell%(voice%)+son%+1,0,voice%) = array%(holdstartcell%(voice%)+son%+1,0,voice%) + 1000000
   ENDIF

  WHEN "move&drag" :

   array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) + 60000
   IF  (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3 > 900 THEN
    number% = (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3
    array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) - (number%*1000)
    array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) + 1000000
   ENDIF

bar1% = (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^6)
beat1% = (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3
position1% = (bar1%*960) + beat1%
bar2% = (array%(holdstartcell%(voice%)+son%-1,0,voice%)DIV10^6)
beat2% = (array%(holdstartcell%(voice%)+son%-1,0,voice%)DIV10^3)MOD10^3
position2% = (bar2%*960) + beat2%
dur% = position1% - position2%
PROCconvertdur
number% = (array%(holdstartcell%(voice%)+son%-1,1,voice%)DIV10)MOD10^3
array%(holdstartcell%(voice%)+son%-1,1,voice%) = array%(holdstartcell%(voice%)+son%-1,1,voice%) - (number%*10)
array%(holdstartcell%(voice%)+son%-1,1,voice%)  = array%(holdstartcell%(voice%)+son%-1,1,voice%) + (dur%*10)


  WHEN "duration" :

array%(holdstartcell%(voice%)+son%,1,voice%) = array%(holdstartcell%(voice%)+son%,1,voice%) + 10
IF (array%(holdstartcell%(voice%)+son%,1,voice%)DIV10)MOD10^3 > 998 THEN (array%(holdstartcell%(voice%)+son%,1,voice%)DIV10)MOD10^3 = 998
ENDCASE


 PROCdisplay

WHEN "<" :
 voice% = displayvoices%(voix%+(startv%-1))-1

 CASE editwhat$ OF
  WHEN "1stenvelope" :
   array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) - 100000
  WHEN "2ndenvelope" :
   array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) - 10000000

  WHEN "1stamplitude" :
   array%(holdstartcell%(voice%)+son%,1,voice%) = array%(holdstartcell%(voice%)+son%,1,voice%) - 1
   IF array%(holdstartcell%(voice%)+son%,1,voice%)MOD10 = 9 THEN
    array%(holdstartcell%(voice%)+son%,1,voice%) = array%(holdstartcell%(voice%)+son%,1,voice%) + 9
   ENDIF


  WHEN "2ndamplitude" :
   IF (array%(holdstartcell%(voice%)+son%,2,voice%)DIV10^2)MOD10 = 0 THEN
    array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) + 800
   ELSEarray%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) - 100
   ENDIF

  WHEN "3rdamplitude" :
   array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) - 1000

   IF (array%(holdstartcell%(voice%)+son%,2,voice%)DIV10^3)MOD10 = 9 THEN
    array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) + 9000
   ENDIF


  WHEN "4thamplitude" :
   array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) - 10000
   IF (array%(holdstartcell%(voice%)+son%,2,voice%)DIV10^4)MOD10 = 9 THEN
    array%(holdstartcell%(voice%)+son%,2,voice%) = array%(holdstartcell%(voice%)+son%,2,voice%) + 90000
   ENDIF

 WHEN "movetwo" :

   array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) - 60000
   IF  (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3 > 900 THEN
    number% = (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3
    array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) - (number%*1000)
    array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) + 900000
   ENDIF

   array%(holdstartcell%(voice%)+son%+1,0,voice%) = array%(holdstartcell%(voice%)+son%+1,0,voice%) - 60000
   IF  (array%(holdstartcell%(voice%)+son%+1,0,voice%)DIV10^3)MOD10^3 > 900 THEN
    number% = (array%(holdstartcell%(voice%)+son%+1,0,voice%)DIV10^3)MOD10^3
    array%(holdstartcell%(voice%)+son%+1,0,voice%) = array%(holdstartcell%(voice%)+son%+1,0,voice%) - (number%*1000)
    array%(holdstartcell%(voice%)+son%+1,0,voice%) = array%(holdstartcell%(voice%)+son%+1,0,voice%) + 900000
   ENDIF


 WHEN "move&drag" :

   array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) - 60000
   IF  (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3 > 900 THEN
    number% = (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3
    array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) - (number%*1000)
    array%(holdstartcell%(voice%)+son%,0,voice%) = array%(holdstartcell%(voice%)+son%,0,voice%) + 900000
   ENDIF


bar1% = (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^6)
beat1% = (array%(holdstartcell%(voice%)+son%,0,voice%)DIV10^3)MOD10^3
position1% = (bar1%*960) + beat1%
bar2% = (array%(holdstartcell%(voice%)+son%-1,0,voice%)DIV10^6)
beat2% = (array%(holdstartcell%(voice%)+son%-1,0,voice%)DIV10^3)MOD10^3
position2% = (bar2%*960) + beat2%
dur% = position1% - position2%
PROCconvertdur
number% = (array%(holdstartcell%(voice%)+son%-1,1,voice%)DIV10)MOD10^3
array%(holdstartcell%(voice%)+son%-1,1,voice%) = array%(holdstartcell%(voice%)+son%-1,1,voice%) - (number%*10)
array%(holdstartcell%(voice%)+son%-1,1,voice%)  = array%(holdstartcell%(voice%)+son%-1,1,voice%) + (dur%*10)


  WHEN "duration" :

array%(holdstartcell%(voice%)+son%,1,voice%) = array%(holdstartcell%(voice%)+son%,1,voice%) - 10
ENDCASE

 PROCdisplay

  :
OTHERWISE PROCawait
 :
 ENDCASE
 ENDPROC
 :
 REM**********************************************
 :
 DEF PROCrhythmdisplay
 :
 IF longscore$ = "n" THEN finalbar% = (firstbar%+((numbars%/2)))-1 ELSE finalbar% = (firstbar%+(numbars%))-1
 FOR bar% = firstbar% TO finalbar%
 :
 rgroup%(1) = disarray%(bar%,0,voice%)DIV10^3
 rgroup%(2) = ((disarray%(bar%,0,voice%)MOD10^3)*10^3)+(disarray%(bar%,1,voice%)DIV10^6)
 rgroup%(3) = disarray%(bar%,1,voice%)MOD10^6
 rgroup%(4) = disarray%(bar%,2,voice%)DIV10^3
 rgroup%(5) = disarray%(bar%,3,voice%)
  :
 FOR group% = 1 TO 5
  :
   IF rgroup%(group%) <> 0 THEN
    IF group% < 5 THEN
     beat% = rgroup%(group%)DIV10^4
     addition% = (960*factor)*(bar%-firstbar%)
     leftend% = (beat%*beatfactor%)
     grouplength% = ((rgroup%(group%)MOD10^4)DIV10^2)*beatfactor%
     divs% = (rgroup%(group%)MOD10^2)
     rightend% = leftend%+((grouplength%/divs%)*(divs%-1))
    ELSE
     beat% = rgroup%(group%)DIV10^7
     addition% = (960*factor)*(bar%-firstbar%)
     leftend% = (beat%*beatfactor%)
     grouplength% = ((rgroup%(group%)MOD10^7)DIV10^4)*beatfactor%
     divs% = (rgroup%(group%)MOD10^4)
     rightend% = leftend%+((grouplength%/divs%)*(divs%-1))
    ENDIF
  :
  value = divs%/(grouplength%/beatfactor%)
   :
   IF value >= 1 AND value < 2 THEN change% = 0
   IF value >= 2 AND value < 4 THEN change% = 1
   IF value >= 4 AND value < 8 THEN change% = 2
   IF value >= 8 AND value < 16 THEN change% = 3
   IF value >= 0.5 AND value < 1 THEN change% = -1
   IF value >= 0.25 AND value < 0.5 THEN change% = -2
   IF value >= 0.125 AND value < 0.25 THEN change% = -3
   IF value >= 0.0625 AND value < 0.125 THEN change% = -4
   IF value >= 0.03125 AND value < 0.0625 THEN change% = -5
   numbeams% = beams% + change%
   IF numbeams% < 0 THEN numbeams% = 0
 :
 IF longscore$ = "n" THEN v% = 938 + shortbeamposn%(voice%) ELSE v% = actbeamposn%(count%-startv%)
 IF longscore$ = "n" THEN
  IF shortstemdir$(voice%) = "D" THEN x% = -12 ELSE x% = 12
 ELSE IF longstemdir$(voice%) = "D" THEN x% = -12 ELSE x% = 12
 ENDIF
 IF longscore$ = "n" THEN inc% = 80 ELSE inc% = 120
 :
  IF numbeams% > 0 THEN
 :
 left% = (leftend%*factor)+inc%+addition%
 right% = (rightend%*factor)+inc%+addition%
 gap% = (right% - left%)/(divs%-1)

 FOR times% = 1 TO numbeams%
 pt1% = left%
 space = grouplength%/divs%
 pt2% = ((leftend%*factor)+(inc%+2)+((space*factor)))+addition%
 ct% = -1
 power% = (5-times%)
 IF power% < 1 THEN power% = 1
 n% = 2^power%
  WHILE pt2%<= (right%+10)
    ct% += 1
    IF ((ct%+1)/n%*10)MOD10 <> 0 OR times% = 1 THEN

     LINE pt1%,((v%-(524*(system%-1)))-(x%*(times%-1))),pt2%,((v%-(524*(system%-1)))-(x%*(times%-1)))
     LINE pt1%,(((v%-2)-(524*(system%-1)))-(x%*(times%-1))),pt2%,(((v%-2)-(524*(system%-1)))-(x%*(times%-1)))
     LINE pt1%,(((v%-4)-(524*(system%-1)))-(x%*(times%-1))),pt2%,(((v%-4)-(524*(system%-1)))-(x%*(times%-1)))
REM for beams crossing systems
IF right% > 1600 THEN crossing$ = "y" ELSE crossing$ = "n"
IF crossing$ = "y" AND longscore$ = "n" AND system% = 1 THEN
 LINE pt1%-1600+inc%,((v%-(524*(system%-1)))-(x%*(times%-1)))-524,pt2%-1600+inc%,((v%-(524*(system%-1)))-(x%*(times%-1)))-524

     LINE pt1%-1600+inc%,(((v%-2)-(524*(system%-1)))-(x%*(times%-1)))-524,pt2%-1600+inc%,(((v%-2)-(524*(system%-1)))-(x%*(times%-1)))-524
     LINE pt1%-1600+inc%,(((v%-4)-(524*(system%-1)))-(x%*(times%-1)))-524,pt2%-1600+inc%,(((v%-4)-(524*(system%-1)))-(x%*(times%-1)))-524
ENDIF
    ENDIF
     pt1% = pt2%
     pt2% = ((leftend%*factor)+(inc%+2)+((ct%+2)*(space*factor)))+addition%

  ENDWHILE
    NEXT
   ENDIF
   :
   space = grouplength%/divs%
 IF longscore$ = "y" THEN
  IF longstemdir$(voice%) = "U" THEN dir% = 1 ELSE dir% = -1
 ELSE
  IF shortstemdir$(voice%) = "U" THEN dir% = 1 ELSE dir% = -1
 ENDIF
 :
 FOR counter% = 0 TO (divs%-1)
    REM grouping% adds to length of stems to group in 2's, 4's etc
    grouping% = 0

 CASE shortstemdir$(voice%) OF
  WHEN "D" :
    IF (counter%/2*10)MOD10 = 0 THEN grouping% = -20
    IF (counter%/4*10)MOD10 = 0 THEN grouping% = -40
    IF (counter%/8*10)MOD10 = 0 THEN grouping% = -60
  OTHERWISE
    IF (counter%/2*10)MOD10 = 0 THEN grouping% = 20
    IF (counter%/4*10)MOD10 = 0 THEN grouping% = 40
    IF (counter%/8*10)MOD10 = 0 THEN grouping% = 60
  ENDCASE
    LINE ((leftend%*factor)+(inc%+2)+(counter%*(space*factor)))+addition%,(((v%)-(524*(system%-1)))),((leftend%*factor)+(inc%+2)+(counter%*(space*factor)))+addition%,((((v%)-(524*(system%-1))))-(((numbeams%*12)+32)*dir%)-grouping%)
   NEXT
 REM routine for groups crossing systems
 IF system% = 1 AND longscore$ = "n" AND crossing$ = "y" THEN
FOR counter% = 0 TO (divs%-1)
    LINE (((leftend%*factor)+(inc%+2)+(counter%*(space*factor)))+addition%)-1600+inc%,(((v%)-(524*(system%-1))))-524,(((leftend%*factor)+(inc%+2)+(counter%*(space*factor)))+addition%)-1600+inc%,(((v%)-(524*(system%-1))))-(((numbeams%*12)+32)*dir%)-524
    :
   NEXT
 ENDIF
   :
  hposition% = (leftend%*factor)+inc%+addition%+(grouplength%/divs%*(divs%-1)/2*factor)
  vposition% =((v%+32)-(524*(system%-1)))
 REM routine for groups crossing systems
  IF hposition% > 2112 THEN
   hposition% = hposition% - 2062
   vposition% = vposition% - 524
  ENDIF
 IF longscore$ = "y" THEN
  IF longstemdir$(voice%) = "D" THEN vposition% -= 50
 ELSE
  IF shortstemdir$(voice%) ="D" THEN vposition% -= 50
 ENDIF
  IF longstemdir$(voice%) = "U" THEN vposition% -= 6
  IF shortstemdir$(voice%) ="U" THEN vposition% -= 6
 :
   grouplength% = grouplength%/beatfactor%
   lownum% = grouplength%
   IF change% = 0 THEN decimal% = 0
   IF change% = 1 THEN lownum% = lownum%*2 : decimal% = 0
   IF change% = 2 THEN lownum% = lownum%*4 : decimal% = 0
   IF change% = 3 THEN lownum% = lownum%*8 :  decimal% = 0
   IF change% = -1 THEN lownum = lownum%/2 : decimal% = (lownum*10)MOD10 : lownum% = lownum*1
   IF change% = -2 THEN lownum = lownum%/4 : decimal% = (lownum*10)MOD10 : lownum% = lownum*1
   IF change% = -3 THEN lownum = lownum%/8 : decimal% = (lownum*10)MOD10 : lownum% = lownum*1
   IF change% = -4 THEN lownum = lownum%/16 :decimal% = (lownum*10)MOD10 : lownum% = lownum*1
   IF change% = -5 THEN lownum = lownum%/32 :decimal% = (lownum*10)MOD10 : lownum% = lownum*1
   :
  printname$ = "n"
  WHILE ((divs%/2)*10)MOD10 = 0 AND ((lownum%/2)*10)MOD10 = 0 AND decimal% = 0
   divs% = divs%/2 : lownum% = lownum%/2 : change% -= 1 : printname$ = "y"
  ENDWHILE
  IF change% < -2 THEN printname$ = "y"
 :
VDU 23,128,32,32,32,32,32,32,32,32
VDU 23,129,48,40,36,34,32,32,32,32
VDU 23,130,48,40,36,50,40,36,34,32
VDU 23,131,36,34,32,32,32,32,32,32
VDU 23,132,48,40,36,50,40,36,50,40
VDU 23,133,36,50,40,36,50,32,32,32
VDU 23,134,36,50,40,36,50,40,36,34
VDU 23,135,1,1,1,29,63,63,62,28
VDU 23,136,0,0,1,1,1,1,1,1
VDU 23,137,1,1,1,29,35,35,34,28
VDU 23,138,0,0,0,28,34,34,34,28
:
MOVE hposition%,vposition%
  IF divs% < 10 THEN VDU 8
  IF divs% >= 10 THEN
   VDU 8 : VDU 8
  ENDIF
   :
   IF decimal% = 0 THEN
    IF divs% <> lownum% THEN
     IF printname$ = "y" THEN
     PRINT ,;divs%;":";lownum%;
     CASE change% OF
      WHEN 3 : PRINT"//////"
      WHEN 2 : PRINT CHR$(134)  : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(132)
      WHEN 1 : PRINT CHR$(133)  : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM  IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(132)
      WHEN 0 : PRINT CHR$(131)  : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM  IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(132)
      WHEN -1 : PRINT CHR$(128) : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(130)
      WHEN -2 : PRINT CHR$(128) : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(129)
      WHEN -3 : PRINT CHR$(135) : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(136)
      WHEN -4 : PRINT CHR$(137) : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(136)
      WHEN -5 : PRINT CHR$(138)
      OTHERWISE
     ENDCASE
     ELSE PRINT ,;divs%;":";lownum%
     ENDIF
    ENDIF
   ELSE PRINT ,;divs%;":";lownum%;".";decimal%;
   CASE change% OF
    WHEN -1 : PRINT CHR$(128) : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";".";decimal%;
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(130)
      WHEN -2 : PRINT CHR$(128) : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";".";decimal%;
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(129)
      WHEN -3 : PRINT CHR$(135) : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";".";decimal%;
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(136)
      WHEN -4 : PRINT CHR$(137) : MOVE hposition%,vposition%+16
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";".";decimal%;
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(136)
      WHEN -5 : PRINT CHR$(138)
      OTHERWISE
     ENDCASE
   ENDCASE
   ENDIF
   :
   REM routine for groups crossing systems
   IF system% = 1 AND longscore$ = "n" AND crossing$ = "y" THEN
MOVE hposition%-1600+inc%,vposition%-524
  IF divs% < 10 THEN VDU 8
  IF divs% >= 10 THEN
   VDU 8 : VDU 8
  ENDIF
   :
   IF decimal% = 0 THEN
    IF divs% <> lownum% THEN
     IF printname$ = "y" THEN
     PRINT ,;divs%;":";lownum%;
     CASE change% OF
      WHEN 3 : PRINT"//////"
      WHEN 2 : PRINT CHR$(134)  : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM  IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(132)
      WHEN 1 : PRINT CHR$(133)  : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM  IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(132)
      WHEN 0 : PRINT CHR$(131)  : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM  IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(132)
      WHEN -1 : PRINT CHR$(128) : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(130)
      WHEN -2 : PRINT CHR$(128) : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(129)
      WHEN -3 : PRINT CHR$(135) : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(136)
      WHEN -4 : PRINT CHR$(137) : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(136)
      WHEN -5 : PRINT CHR$(138)
      OTHERWISE
     ENDCASE
     ELSE PRINT ,;divs%;":";lownum%
     ENDIF
    ENDIF
   ELSE PRINT ,;divs%;":";lownum%;".";decimal%;
   CASE change% OF
    WHEN -1 : PRINT CHR$(128) : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
       VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";".";decimal%;
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(130)
      WHEN -2 : PRINT CHR$(128) : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";".";decimal%;
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(129)
      WHEN -3 : PRINT CHR$(135) : MOVE hposition%-1600,+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";".";decimal%;
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(136)
      WHEN -4 : PRINT CHR$(137) : MOVE hposition%-1600+inc%,vposition%+16-524
       IF divs% < 10 THEN VDU 8
       IF divs% >= 10 THEN
        VDU 8 : VDU 8
       ENDIF
      REM   IF printing$ = "n" THEN GCOL 63 ELSE GCOL 0
PRINT ,;"   ";".";decimal%;
 REM IF printing$ = "n" THEN GCOL 0 ELSE GCOL 63
PRINT CHR$(136)
      WHEN -5 : PRINT CHR$(138)
      OTHERWISE
     ENDCASE
   ENDCASE
   ENDIF
  ENDIF
  :
  ENDIF
  NEXT
  :
 NEXT
 :
 ENDPROC
 :
 REM*******************************************************
 :
 DEF PROCdisplaysubmenu
 :
 IF easiermenus$ = "n" THEN
 PROCwindow(20,66,60,39)
 CLS   : OFF
 PRINT'" Notehead sizes          N"
 PRINT " Longscore/Shortscore    L"
 PRINT " Stem lengths            S"
 PRINT " Beats posns/frequecy    P"
 PRINT " Beat numbers/diffs      I"
 PRINT " Beat numbers/diffs unit J"
 PRINT " Dynamics positions      F"
 PRINT " Note number freq        G"
 PRINT " Bar numbers             Z"
 PRINT " Intervals settings      Q"
 PRINT " Remove:               "
 PRINT "  staves, ledgers, clefs C"
 PRINT "  lower stave (shrt sc)  U"
 PRINT "  barlines               B"
 PRINT "  beats                  T"
 PRINT "  names, voice numbers   V"
 PRINT "  accidentals            A"
 PRINT "  stems, beams           R"
 PRINT "  durations              D"
 PRINT "  amplitudes             M"
 PRINT "  beat numbers (n,1st,y) O"
 PRINT "  notenumbers            H"
 PRINT "  notenames              E"
 PRINT "  intervals              K"
 PRINT "  play screen renew      Y"
 PRINT "  all except noteheads   X"
 ELSE
PROCwindow(20,66,60,12)
 CLS   : OFF
 PRINT'" Notehead sizes          N"
 PRINT '" Longscore/Shortscore    L"
 PRINT '" Stem lengths            S"
 PRINT '" Beats posns/frequecy    P"
 PRINT '" Beat numbers/diffs      I"
 PRINT '" Beat numbers/diffs unit J"
 PRINT '" Dynamics positions      F"
 PRINT '" Note number freq        G"
 PRINT '" Bar numbers             Z"
 PRINT '" Intervals settings      Q"
 PRINT '" Remove:               "
 PRINT '"  staves, ledgers, clefs C"
 PRINT '"  lower stave (shrt sc)  U"
 PRINT '"  barlines               B"
 PRINT '"  beats                  T"
 PRINT '"  names, voice numbers   V"
 PRINT '"  accidentals            A"
 PRINT '"  stems, beams           R"
 PRINT '"  durations              D"
 PRINT '"  dynamics               M"
 PRINT '"  beat numbers (n,1st,y) O"
 PRINT '"  notenumbers            H"
 PRINT '"  notenames              E"
 PRINT '"  intervals              K"
 PRINT '"  play screen renew      Y"
 PRINT '"  all except noteheads   X"
 ENDIF
 :
 CASE GET$ OF
  WHEN "E","e" :
   IF notenames$ = "y" THEN notenames$ = "n" ELSE notenames$ = "y"
  WHEN "N","n" :
 CLS
   PRINT'" What size note-heads? (B/S/V) "
   CASE GET$ OF
    WHEN "B","b" : notehead$ = "big"
    WHEN "S","s" : notehead$ = "small"
    WHEN "V","v" : notehead$ = "vsmall"
   ENDCASE
  WHEN "L","l" :
   IF longscore$ = "n" THEN longscore$ = "y" ELSE longscore$ = "n"
   IF longscore$ = "n" THEN
    startv1% = startv% : startv% =1
  ELSE startv% = startv1%
  ENDIF
  WHEN "S","s" :
 CLS
   INPUT'" Which voice "voys%
   voys% -= 1
   PRINT'" stems to end how many"
   PRINT" octaves from top"
   INPUT" stave-line (0,1,-1 etc) "st
 INPUT " stems up or down (U/D)"stemdir$
  IF longscore$ = "n" THEN
   shortbeamposn%(voys%) = st*56
   IF shortbeamposn%(voys%) <= -112 THEN shortbeamposn%(voys%)-=48
   shortstemdir$(voys%) = stemdir$
  ENDIF
  IF longscore$ = "y" THEN
   longbeamposn%(voys%) = st*56
   longstemdir$(voys%) = stemdir$
  ENDIF
   :
   WHEN "P","p" :
   CLS
PRINT'" Beats positions or frequecy (P/F)"
CASE GET$ OF
WHEN "P","p" :
   INPUT'" Upper or lower beats (U/L)"whichset$
   PRINT '" up or down by how many"
   INPUT " stave-lines (1,-1 etc)"move%
   IF whichset$ = "U" THEN
    longbeatsupper% += (move%*16)
   ELSE longbeatslower% += (move%*16)
   ENDIF
OTHERWISE
PRINT'" Beats frequency doubled/halved (+/-) "
CASE GET$ OF
 WHEN "+","=" : beatstep% = beatstep%/2
 WHEN "_","-" : beatstep% = beatstep%*2
 OTHERWISE
ENDCASE
:
ENDCASE
 :
  WHEN "Z","z" : CLS : INPUT'" Bar nos how often (1,2 etc) "barnosoften%
  WHEN "Y","y" :
   IF playnewscreen$ = "y" THEN playnewscreen$ = "n" ELSE playnewscreen$ = "y"
  WHEN "I","i" :
   IF beatnum_diff$ = "num" THEN beatnum_diff$ = "diff" ELSE beatnum_diff$ = "num"
  WHEN "J","j" :
   IF beatunits$ = "big" THEN beatunits$ = "small" ELSE beatunits$ = "big"
  WHEN "C","c" :
   IF staves$ = "y" THEN staves$ = "n" ELSE staves$ = "y"
  WHEN "B","b" :
   IF barlines$ = "y" THEN barlines$ = "n" ELSE barlines$ = "y"
  WHEN "T","t" :
   IF beats$ = "y" THEN beats$ = "n" ELSE beats$ = "y"
  WHEN "U","u" :
   IF lowerstave$ = "y" THEN lowerstave$ = "n" ELSE lowerstave$ = "y"
  WHEN "V","v" :
   IF names$ = "y" THEN names$ = "n" ELSE names$ = "y"
  WHEN "A","a" :
   IF accidentals$ = "y" THEN accidentals$ = "n" ELSE accidentals$ = "y"
  WHEN "R","r" :
   IF stems$ = "y" THEN stems$ = "n" ELSE stems$ = "y"
  WHEN "D","d" :
   IF durations$ = "y" THEN durations$ = "n" ELSE durations$ = "y"
  WHEN "M","m" :
   CASE amplitudes$ OF
    WHEN "n" : amplitudes$ = "y"
    WHEN "y" : amplitudes$ = "stepped"
    WHEN "stepped" : amplitudes$ = "n"
   ENDCASE
  WHEN "O","o" :
   CASE beatnumbers$ OF
    WHEN "y" : beatnumbers$ = "n"
    WHEN "n" : beatnumbers$ = "first"
    WHEN "first" : beatnumbers$ = "y"
   ENDCASE
  WHEN "H","h" :
   CASE notenumbers$ OF
    WHEN "last" : notenumbers$ = "n"
    WHEN "y" : notenumbers$ = "last"
    WHEN "from1" : notenumbers$ = "y"
    WHEN "n" : notenumbers$ = "from1"
  ENDCASE
  WHEN "F","f" :

 CLS
   INPUT'" Which voice "voys%
   voys% -= 1
   PRINT' " dynamics up/down by how many "
   INPUT " stave-lines (1,-1 etc) "dy%
   dy% = dy%*16
   IF longscore$ = "y" THEN
    longamppos%(voys%) += dy%
   ELSE shortamppos%(voys%) += dy%
   ENDIF
 WHEN "G","g" :
  CLS
  PRINT'" Note numbers every 1/2/4/10 notes (0 = 10) "
  CASE GET$ OF
   WHEN "1" : nosevery% = 1
   WHEN "2" : nosevery% = 2
   WHEN "4" : nosevery% = 4
   OTHERWISE nosevery% = 10
  ENDCASE
  INPUT' " starting at note number "startnos%
  :
 WHEN "Q","q" :
   CLS
   PRINT'" Set number/type of intervals displayed"
   PRINT" or compound reduction point? (N/C)"
   CASE GET$ OF
    WHEN "N","n" :
     PRINT'" Display intervals for how"
     INPUT" many previous notes "numintervals%
     PRINT'" Semitones, quartertones, "
     PRINT" eighthtones or cents (S/Q/E/C) "
     CASE GET$ OF
      WHEN "S","s" : typeintervals$ = "s"
      WHEN "Q","q" : typeintervals$ = "q"
      WHEN "E","e" : typeintervals$ = "e"
      WHEN "C","c" : typeintervals$ = "c"
ENDCASE
    WHEN "C","c" :
     PRINT'" Above which interval should"
     PRINT" compounds be reduced for "
     INPUT" the current interval type "compound%
     CASE typeintervals$ OF
      WHEN "s" : compoundpitch% = compound%
      WHEN "q" : compoundquarter% = compound%
      WHEN "e" : compoundeighth% = compound%
      WHEN "c" : compoundcent% = compound%
     ENDCASE
    ENDCASE
  WHEN "K","k" :
   IF displayintervals$ = "y" THEN displayintervals$ = "n" ELSE displayintervals$ = "y"
  WHEN "X","x" :
   IF xoption$ = "y" THEN xoption$ = "n" ELSE xoption$ = "y"
   IF xoption$ = "y" THEN
    staves$ = "y" : barlines$ = "y" : beats$ = "y" : names$ = "y"
    accidentals$ = "y" : stems$ = "y" : durations$ = "y"
    amplitudes$ = "y" : envelopes$ = "y" : glissandos$ = "y"
   beatnumbers$ = "y"
   ELSE
    staves$ = "n" : barlines$ = "n" : beats$ = "n" : names$ = "n"
    accidentals$ = "n" : stems$ = "n" : durations$ = "n"
    amplitudes$ = "n" : envelopes$ = "n" : glissandos$ = "n"
   beatnumbers$ = "n"
   ENDIF
   OTHERWISE VDU 7 : PROCdisplaysubmenu
  ENDCASE
 ON
 PROCdisplay
 ENDPROC
 :
 REM*********************************************************
 :
 DEF PROCclef(numstaves%,staves%(1),staves%(2),staves%(3),staves%(4),staves%(5),staves%(6),clefcomb$)
 :
  IF staves$ = "y" THEN
 FOR count% = 1 TO numstaves%
  IF MID$(clefcomb$,count%,1) = "T" OR MID$(clefcomb$,count%,1) = "P" THEN
   LINE 48,staves%(count%)+20,52,staves%(count%)+20
   LINE 44,staves%(count%)+16,56,staves%(count%)+16
   LINE 42,staves%(count%)+12,52,staves%(count%)+12
   LINE 58,staves%(count%)+12,58,staves%(count%)+12
   LINE 40,staves%(count%)+8,48,staves%(count%)+8
   LINE 58,staves%(count%)+8,58,staves%(count%)+8
   LINE 40,staves%(count%)+4,42,staves%(count%)+4
   LINE 58,staves%(count%)+4,58,staves%(count%)+4
   LINE 38,staves%(count%)+0,40,staves%(count%)+0
   LINE 54,staves%(count%)+0,56,staves%(count%)+0
   LINE 38,staves%(count%)-4,38,staves%(count%)-4
   LINE 50,staves%(count%)-4,54,staves%(count%)-4
   LINE 38,staves%(count%)-8,38,staves%(count%)-8
   LINE 46,staves%(count%)-8,52,staves%(count%)-8
   LINE 36,staves%(count%)-12,52,staves%(count%)-12
   LINE 32,staves%(count%)-16,50,staves%(count%)-16
   LINE 24,staves%(count%)-20,44,staves%(count%)-20
   LINE 20,staves%(count%)-24,42,staves%(count%)-24
   LINE 14,staves%(count%)-28,26,staves%(count%)-28
   LINE 42,staves%(count%)-28,42,staves%(count%)-28
   LINE 12,staves%(count%)-32,22,staves%(count%)-32
   LINE 42,staves%(count%)-32,42,staves%(count%)-32
   LINE 12,staves%(count%)-36,22,staves%(count%)-36
   LINE 34,staves%(count%)-36,52,staves%(count%)-36
   LINE 10,staves%(count%)-40,18,staves%(count%)-40
   LINE 30,staves%(count%)-40,56,staves%(count%)-40
   LINE 10,staves%(count%)-44,14,staves%(count%)-44
   LINE 24,staves%(count%)-44,32,staves%(count%)-44
   LINE 42,staves%(count%)-44,42,staves%(count%)-44
   LINE 56,staves%(count%)-44,60,staves%(count%)-44
   LINE 10,staves%(count%)-48,14,staves%(count%)-48
   LINE 24,staves%(count%)-48,32,staves%(count%)-48
   LINE 42,staves%(count%)-48,42,staves%(count%)-48
   LINE 56,staves%(count%)-48,60,staves%(count%)-48
   LINE 10,staves%(count%)-52,16,staves%(count%)-52
   LINE 24,staves%(count%)-52,26,staves%(count%)-52
   LINE 42,staves%(count%)-52,42,staves%(count%)-52
   LINE 56,staves%(count%)-52,60,staves%(count%)-52
   LINE 12,staves%(count%)-56,16,staves%(count%)-56
   LINE 28,staves%(count%)-56,30,staves%(count%)-56
   LINE 42,staves%(count%)-56,42,staves%(count%)-56
   LINE 56,staves%(count%)-56,60,staves%(count%)-56
   LINE 18,staves%(count%)-60,22,staves%(count%)-60
   LINE 42,staves%(count%)-60,42,staves%(count%)-60
   LINE 52,staves%(count%)-60,58,staves%(count%)-60
   LINE 22,staves%(count%)-64,54,staves%(count%)-64
   LINE 42,staves%(count%)-68,42,staves%(count%)-68
   LINE 42,staves%(count%)-72,42,staves%(count%)-72
   LINE 22,staves%(count%)-76,28,staves%(count%)-76
   LINE 42,staves%(count%)-76,42,staves%(count%)-76
   LINE 18,staves%(count%)-80,32,staves%(count%)-80
   LINE 42,staves%(count%)-80,42,staves%(count%)-80
   LINE 14,staves%(count%)-84,28,staves%(count%)-84
   LINE 44,staves%(count%)-84,44,staves%(count%)-84
   LINE 14,staves%(count%)-88,22,staves%(count%)-88
   LINE 44,staves%(count%)-88,44,staves%(count%)-88
   LINE 24,staves%(count%)-92,42,staves%(count%)-92
  IF MID$(clefcomb$,count%,1) = "P" THEN
    MOVE 42,staves%(count%)+44
    PRINT;"8"
  ENDIF
  ENDIF
  IF MID$(clefcomb$,count%,1) = "B" OR MID$(clefcomb$,count%,1) = "D" THEN
   LINE 20,staves%(count%)-4,38,staves%(count%)-4
   LINE 16,staves%(count%)-8,18,staves%(count%)-8
   LINE 38,staves%(count%)-8,44,staves%(count%)-8
   LINE 58,staves%(count%)-8,60,staves%(count%)-8
   LINE 12,staves%(count%)-12,24,staves%(count%)-12
   LINE 40,staves%(count%)-12,48,staves%(count%)-12
   LINE 12,staves%(count%)-16,28,staves%(count%)-16
   LINE 40,staves%(count%)-16,48,staves%(count%)-16
   LINE 16,staves%(count%)-20,28,staves%(count%)-20
   LINE 40,staves%(count%)-20,48,staves%(count%)-20
   LINE 20,staves%(count%)-24,24,staves%(count%)-24
   LINE 40,staves%(count%)-24,48,staves%(count%)-24
   LINE 58,staves%(count%)-24,60,staves%(count%)-24
   LINE 40,staves%(count%)-28,48,staves%(count%)-28
   LINE 40,staves%(count%)-32,48,staves%(count%)-32
   LINE 36,staves%(count%)-36,44,staves%(count%)-36
   LINE 32,staves%(count%)-40,40,staves%(count%)-40
   LINE 28,staves%(count%)-44,34,staves%(count%)-44
   LINE 20,staves%(count%)-48,30,staves%(count%)-48
   LINE 10,staves%(count%)-52,18,staves%(count%)-52
   IFMID$(clefcomb$,count%,1) = "D" THEN
    MOVE 10,staves%(count%)-56
    PRINT;"8"
   ENDIF
  ENDIF
 NEXT
  ENDIF
 :
  IF names$ = "y" THEN
 stave% = 1
 FOR count% = 0 TO lastcount%
  IF MID$(clefcomb$,count%+1,1) = "P" THEN MOVE 20,staves%(stave%)+78 ELSE MOVE 20,staves%(stave%)+58
  PRINT longinsts$(count%,0);
  PRINT;"(";displayvoices%(startv%+count%);")" : REM voice number
  stave% += EVAL(MID$(stavecombination$,count%+1,1))
 NEXT
  ENDIF
 :
 REM defining actamppos%() values
  stave% = 1
  FOR count% = 0 TO lastcount%
   IF MID$(stavecombination$,count%+1,1) = "1" THEN
    actamppos%(displayvoices%(startv%+count%)) = staves%(stave%)-128+longamppos%(displayvoices%(startv%+count%)-1)
   ELSE actamppos%(displayvoices%(startv%+count%)) = staves%(stave%)-224+longamppos%(displayvoices%(startv%+count%)-1)
   ENDIF
   stave% += EVAL(MID$(stavecombination$,count%+1,1))
  NEXT
 :
 :
 REM barlines
 IF barlines$ = "y" THEN
  stave% = 1
  FOR system% = 0 TO lastcount%
   FOR barline% = 1 TO numbars%
    horpos% = (960*barline%*factor)+80
   IF notehead$ = "small" THEN horpos% += 16
   IF notehead$ = "vsmall" THEN horpos% += 24
    FOR thickness% = 2 TO 8 STEP 2
     IF MID$(stavecombination$,system%+1,1) = "1" THEN
      LINE horpos%+thickness%,staves%(stave%),horpos%+thickness%,staves%(stave%)-64
    ELSE
      LINE horpos%+thickness%,staves%(stave%),horpos%+thickness%,staves%(stave%)-160
    ENDIF
   NEXT
 REM bar nos
 IF printing$ = "n" THEN GCOL 3
  IF tempi%(startbar%) <> tempi%(startbar%-1) THEN
   MOVE 40,1145 : PRINT "b.";startbar%;" MM.";tempi%(startbar%)
  ELSE MOVE 40,1145 : PRINT "b.";startbar%;" (MM.";tempi%(startbar%);")"
  ENDIF
 IF remarks$(startbar%,0) <> "" OR remarks$(startbar%,1) <> "" THEN
  MOVE 40,1120 : PRINT remarks$(startbar%,0) : MOVE 40,1095 : PRINT remarks$(startbar%,1)
 ENDIF
 IF printing$ = "n" THEN GCOL 0
 IF system% = 0  THEN
 IF printing$ = "n" THEN GCOL 3
 IF tempi%(startbar%+barline%) <> tempi%(startbar%+barline%-1) THEN
 MOVE horpos%-125,1145 : PRINT startbar%+barline%;" MM.";tempi%(startbar%+barline%)
 ELSE IF barline% MOD barnosoften% = 0 THEN MOVE horpos%-125,1145 : PRINT startbar%+barline%
 ENDIF
 IF remarks$(startbar%+barline%,0) <> "" OR remarks$(startbar%+barline%,1) <> "" THEN
  MOVE horpos%,1120 : PRINT remarks$(startbar%+barline%,0)
  MOVE horpos%,1095 : PRINT remarks$(startbar%+barline%,1)
 ENDIF
REM print duration at bottom right
IF seeduration$ = "y" THEN
IF startbar% + barline% = startbar% + numbars% - 1 THEN
totaldur = 0
FOR count% = 1 TO startbar% + numbars% - 1
duration = 60/tempi%(count%)
totaldur = totaldur + duration
NEXT
totaldur% = totaldur
mins% = totaldur% DIV 60
secs% = totaldur% - (mins%*60)
MOVE 1200,50 : PRINT "duration ";mins%;" mins ";secs%;" secs"
ENDIF
ENDIF
 IF printing$ = "n" THEN GCOL 0
 ENDIF
  NEXT
   stave% += EVAL(MID$(stavecombination$,system%+1,1))
 NEXT
 ENDIF
 :
 ENDPROC
 :
 REM*************************************************
 :
 DEF PROClongvalue(pos%(0),pos%(1),pos%(2),clefcomb$)
 :
 staff% = 1
 finish% = endv%-startv%
 IF finish% > 2 THEN finish% = 2
 FOR ct% = 0 TO finish%
  CASE MID$(clefcomb$,staff%,1) OF
   WHEN "P" : decrement% = 360
   WHEN "T" : decrement% = 304
   WHEN "B" : decrement% = 208
   WHEN "D" : decrement% = 152
  ENDCASE
  value%(ct%) = pos%(ct%) - decrement%
  staff% += EVAL(MID$(stavecombination$,ct%+1,1))
 NEXT
 :
 FOR ct% = 0 TO finish%
  actbeamposn%(ct%) = longbeamposn%(displayvoices%(startv%+ct%)-1) + pos%(ct%)
 NEXT
 ENDPROC
 :
 REM*************************************************
 :
 DEF PROCconvertdur
 :
 REM converts dur% from beats to 1/20ths of a second
 converter = (60 * 20)/(tempi%(barno%) * 960)
 dur = dur% * converter
 fraction = ((dur*10)DIV1)MOD10
 IF fraction>4 THEN dur% = dur+1 ELSE dur% = dur
 IF dur% = 0 THEN dur% = 1
  IF dur% > 999 THEN dur% = 998 : REM max 3 array cells available
 :
 ENDPROC
 :
 REM**********************************************
 :
 DEF PROCreconvertdur
 :
 converter = (60 * 20)/(tempi%(brrr%) * 960)
 dur% = dur%/converter
 :
 ENDPROC
 :
 REM************************************************
 :
 DEF PROCseriesdurations
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,69,60,55) ELSE PROCwindow(20,69,60,42)
 CLS
 PRINT'" How many durations "
 PRINT'" (to fill gaps between attacks "
 PRINT'" press 111 or to half-fill gaps "
 INPUT'" between attacks press 222) "numdurations%
 IF numdurations% = 0 THEN numdurations% = 1
 IF numdurations% = 111 OR numdurations% = 222 THEN PROCdurationsbetween
 :
 IF numdurations% = 1 THEN
  PRINT'" the duration is:" : INPUT' " bars "b% : INPUT' " beats "beats%
  PROCalterbeats : dur% = (b%*960)+beats%
  durations%(0) = dur%
 ELSE
  PRINT'" Are all the durations the same?"
  PRINT'" (no = n/2)"
  CASE GET$ OF
  WHEN "N","n","2"
  FOR count% = 0 TO (numdurations% - 1)
  PRINT'" duration ";count%;" is:"
  INPUT'" bars "b%
  INPUT'" beats "beats% : PROCalterbeats
  dur% = (b%*960)+beats%
  durations%(count%) = dur%
  NEXT
  OTHERWISE
  : PRINT'" the duration is:" : INPUT' " bars "b% : INPUT' " beats "beats%
  PROCalterbeats : dur% = (b%*960)+beats%
  FOR count% = 0 TO (numdurations%-1) : durations%(count%) = dur% : NEXT
  ENDCASE
 ENDIF
 :
 REM function can feed durats similarly into durations%()
 :
 PROCinsertdurations
 :
 ENDPROC
 :
 REM***********************************************
 :
 DEF PROCinsertdurations
 :
 CLS
IF seequery$ = "y" THEN
 PRINT'" Do you want to read these "
 PRINT " durations into the array? "
 CASE GET$ OF
  WHEN "N","n" : PROCdisplay : REM durations%() remains intact
  OTHERWISE
 ENDCASE
ENDIF :  REM seequery$
 :
 IF screenvoices$ = "n" THEN


   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
:
IF quickcopy$ = "n" THEN
 INPUT'" Starting at bar number "bars%
 INPUT " beat "beats% : PROCalterbeats
 startat% = (bars%*(10^3))+beats%
ELSE
 INPUT ' " starting at note number "along%
IF along% = 0 THEN along% = 1
along%-=1
 copystartbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  copystartbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
beats% = copystartbeat%
PROCalterbeats
startat% = (copystartbar%*(10^3))+beats%
ENDIF
 :
 PROCsearch(startat%)
 shunt$ = "N"
 :
 FOR count% = startcell% TO (startcell%+(numdurations%-1))
 PROCcellfill(count%,voice%,999,999,999,9,999,durations%(count%-startcell%),99,99)
 NEXT
 :
 PROCdisplay
 :
 ENDPROC
 :
 REM*************************************************
 :
 DEF PROCinsertamplitudes
 :
 CLS
 repeatposit$ = "n"
IF seequery$ = "y" THEN
 PRINT'" Do you want to read these amplitudes "
 PRINT " into the array? "
 CASE GET$ OF
  WHEN "N","n" : PROCdisplay : REM amplitudes%()) remains intact
  OTHERWISE
 ENDCASE
ENDIF : REM seequery$
 :
 IF ampmethod$ = "sample" THEN
 IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
 :
IF quickcopy$ = "y" THEN
INPUT ' " starting at note number "along%
IF along% = 0 THEN along% = 1
 along%-=1
 bars% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
 beats% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  holdbar% = bars%
  holdbeat% = beats%
PROCalterbeats
 startat% = (bars%*(10^3))+beats%
:
ELSE
:
INPUT'" Starting at bar number "bars%
IF bars% = 0 THEN
 bars% = holdbar% : beats% = holdbeat% : repeatposit$ = "y"
ENDIF
 holdbar% = bars%
IF repeatposit$ = "y" THEN
PRINT'" bar ";bars%;" beat ";beats%;"?"
PRINT'" (for OK press 0, if not OK press X)"
CASE GET$ OF
 WHEN"X","x" : PROCinsertpitches
 OTHERWISE
ENDCASE
ELSE
 INPUT " beat "beats%
 holdbeat% = beats%
ENDIF
 PROCalterbeats
 startat% = (bars%*(10^3))+beats%
:
ENDIF
:
 ENDIF
 :
 PROCsearch(startat%)
 shunt$ = "N"
 :
 FOR count% = startcell% TO (startcell%+(numamplitudes%-1))
 PROCcellfill(count%,voice%,999,999,999,amplitudes%(count%-startcell%),999,999,99,99)
 NEXT
 :
 PROCdisplay
 :
 ENDPROC
 :
 REM************************************************
 :
 DEF PROCassignvoices
 :
 IF defaultvoices$ = "y" THEN
  waveforms$() = "WaveSynth-Beep"
 ELSE
  CLS
  PRINT '" Assign waveforms to"
  INPUT" how many voices "vcesx%
   FOR count% = 1 TO vcesx%
    PRINT'"  voice ";count%;" is which voice number"
    INPUT vcen%
    PRINT'"  voice ";vcen%;
    IF insts$(vcen%,0) <> "" THEN PRINT " (";insts$(vcen%,0);")"
    PRINT"  is assigned which waveform?"
    INPUT waveform$
    waveforms$(vcen%) = waveform$
   NEXT
  ENDIF
  :
  ENDPROC
 :
 REM************************************************
 :
 DEF PROCseriesenvelopes
 :
REM envelopes%() and glissandos%() are always input at the same time
 IF easiermenus$ = "n" THEN PROCwindow(20,69,73,45) ELSE  PROCwindow(20,69,73,42)
IF gradations$ = "y" THEN PRINT'" Input gradations as if envelopes with 4 phases "

INPUT'" How many envelopes/glissandos "numenvelopes%
IF numenvelopes% = 0 THEN numenvelopes% = 1
:
IF numenvelopes% > 1 THEN
PRINT '" are the envelopes all the same? "
PRINT '" (Y/0/1, N/2) "
CASE GET$ OF
WHEN "N","n","2" : sameenvelopes$ = "n"
OTHERWISE sameenvelopes$ = "y"
ENDCASE
ELSE
sameenvelopes$ = "y"
ENDIF
:
 FOR count% = 0 TO (numenvelopes%-1)
 IF sameenvelopes$ = "n" OR (sameenvelopes$ ="y" AND count% = 0) THEN

IF numphases% <> 4 THEN
PRINT'" Envelope ";count%+1;
INPUT " has how many phases? "numphases%
ENDIF


:
CASE numphases% OF
:
WHEN 0 :
 INPUT'" amplitude is "amp$ : PROCconvertdynamics : amp1% = amp%
 amp2% = 9
 gliss1% = 50
 ph2% = 0 : ph1% = 0 : amp4% = 0 : amp3% = 0 : gliss3% = 10 : gliss2% = 50
 :
WHEN 4 :
 INPUT'" amplitude is (0 = previous) "amp$
IF amp$ = "" THEN amp$ = prevamp$
COLOUR 3 : PRINT'"         ";amp$
wait$ = INKEY$(20) : COLOUR 0
 PROCconvertdynamics : amp1% = amp%
 INPUT'" gradation is (select from 1-9) "gradation%
IF gradation% = 0 THEN gradation% = prevgradation%
COLOUR 3 : PRINT' gradation%
wait$ = INKEY$(20) : COLOUR 0
 amp2% = 9
 amp3% = gradation%
 gliss1% = 50
 ph2% = 0 : ph1% = 0 : amp4% = 0 : gliss3% = 10 : gliss2% = 50
prevamp$ = amp$ : prevgradation% = gradation%
 :
WHEN 1 :
 INPUT'" starting amplitude is "amp$ : PROCconvertdynamics : amp1% = amp%
 INPUT'" destination amplitude is "amp$ : PROCconvertdynamics : amp2% = amp%
 INPUT'" glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss1% = 50-gliss%
 ph2% = 0 : ph1% = 0 : amp4% = 0 : amp3% = 0 : gliss3% = 10 : gliss2% = 50
:
WHEN 2 :
 INPUT'" starting amplitude is "amp$ : PROCconvertdynamics : amp1% = amp%
 PRINT'" phase 1 ends after what percentage "
 INPUT'" of the note's duration "ph1%
 INPUT'" phase 1's destination amplitude is "amp$ : PROCconvertdynamics : amp2% = amp%
 INPUT'" phase 1's glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss1% = 50-gliss%
 INPUT'" phase 2's destination amplitude is "amp$ : PROCconvertdynamics : amp3% = amp%
 INPUT'" phase 2's glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss2% = 50-gliss%
 ph2% = 0 : amp4% = 0 : gliss3% = 10
:
WHEN 3 :
 INPUT'" starting amplitude is "amp$ : PROCconvertdynamics : amp1% = amp%
 PRINT'" phase 1 ends after what percentage "
 INPUT'" of the note's duration "ph1%
 INPUT'" phase 1's destination amplitude is "amp$ : PROCconvertdynamics : amp2% = amp%
 INPUT'" phase 1's glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss1% = 50-gliss%
 PRINT'" phase 2 ends after what percentage "
 INPUT'" of the note's duration "ph2%
 INPUT'" phase 2's destination amplitude is "amp$ : PROCconvertdynamics : amp3% = amp%
 INPUT'" phase 2's glissando is (in 1/8 tones, max 48,-48) "gliss%
 gliss2% = 50-gliss%
 INPUT'" phase 3's destination amplitude is "amp$ : PROCconvertdynamics : amp4% = amp%
REPEAT
INPUT'" phase 3's glissando is (in 1/8 tones, max 10,-10) "gliss%
 gliss3% = 10-gliss%
IF gliss3% > 20 THEN VDU7
IF gliss3% < 0 THEN VDU7
UNTIL gliss3% < 21 AND gliss3% >= 0
:
ENDCASE
:
  envelopes%(count%) = (ph2%*10^5)+(ph1%*10^3)+(amp4%*10^2)+(amp3%*10)+amp2%
  amplitudes%(count%) = amp1%
  glissandos%(count%) = (gliss3%*10^4)+(gliss2%*10^2)+gliss1%
:
:
 ENDIF
 NEXT
:
IF sameenvelopes$ = "y" THEN
FOR count% = 1 TO (numenvelopes%-1)
  envelopes%(count%) = (ph2%*10^5)+(ph1%*10^3)+(amp4%*10^2)+(amp3%*10)+amp2%
  amplitudes%(count%) = amp1%
  glissandos%(count%) = (gliss3%*10^4)+(gliss2%*10^2)+gliss1%
NEXT
ENDIF
 :
 gradations$ = "n"
 REM function can feed envelopes similarly into envelopes%()
 :
 PROCinsertenvelopes
 :
 ENDPROC
 :
 REM*******************************************
 :
 DEF PROCconvertdynamics
 CASE amp$ OF
  WHEN "0"    : amp% = 0
  WHEN "ppp"   : amp% = 1
  WHEN "pp"   : amp% = 2
  WHEN "p"   : amp% = 3
  WHEN "mp"   : amp% = 4
  WHEN "mf"   : amp% = 5
  WHEN "f"   : amp% = 6
  WHEN "ff"   : amp% = 7
  WHEN "fff"   : amp% = 8
 ENDCASE
 ENDPROC
 :
 REM*******************************************
 :
 DEF PROCinsertenvelopes
 :
 CLS
 repeatposit$ = "n"
IF seequery$ = "y" THEN
 PRINT '" Do you want to read these envelopes into the array?"
 CASE GET$ OF
  WHEN "N","n" : PROCdisplay : REM envelopes%() stays intact
 OTHERWISE
 ENDCASE
ENDIF : REM seequery$
:
IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
:
IF quickcopy$ = "y" THEN
INPUT ' " starting at note number "along%
IF along% = 0 THEN along% = 1
 along%-=1
 bars% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
 beats% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  holdbar% = bars%
  holdbeat% = beats%
PROCalterbeats
 startat% = (bars%*(10^3))+beats%
:
ELSE
:
INPUT'" Starting at bar number "bars%
IF bars% = 0 THEN
 bars% = holdbar% : beats% = holdbeat% : repeatposit$ = "y"
ENDIF
 holdbar% = bars%
IF repeatposit$ = "y" THEN
PRINT'" bar ";bars%;" beat ";beats%;"?"
PRINT" (for OK press 0, if not OK press X)"
CASE GET$ OF
 WHEN"X","x" : PROCinsertpitches
 OTHERWISE
ENDCASE
ELSE
 INPUT " beat "beats%
 holdbeat% = beats%
ENDIF
 PROCalterbeats
 startat% = (bars%*(10^3))+beats%
:
ENDIF
 :
 PROCsearch(startat%)
 shunt$ = "N"
 :
 FOR count% = startcell% TO (startcell%+(numenvelopes%-1))
 PROCcellfill(count%,voice%,999,999,999,amplitudes%(count%-startcell%),envelopes%(count%-startcell%),999,glissandos%(count%-startcell%),99)
 NEXT
 :
 PROCdisplay
 :
 ENDPROC
 :
 REM**********************************************
 :
 DEF PROCseriesinflections
 :
 IF easiermenus$ = "n" PROCwindow(20,69,88,45) ELSE PROCwindow(20,69,88,42)
 PRINT'" semitone = 100 cents  quartertone = 50 cents  eigthtone = 25 cents"
 PRINT " sixteenthtone = 12 cents    sixthtone = 33 cents"
 PRINT'" harmonic 3 = perfect 5th + 2 cents"
 PRINT " harmonic 5 = major 3rd eigthtone flat + 11 cents "
 PRINT " harmonic 7 = minor 7th eightone flat -6 cents"
 PRINT " harmonic 9 = major 2nd + 4 cents"
 PRINT " harmonic 11 = perfect 4th quartertone sharp + 1 cent"
 PRINT " harmonic 13 = major 6th quartertone flat - 9 cents"
 PRINT " harmonic 15 = major 7th - 12 cents"
 INPUT'" How many inflections "numinflections%
 FOR count% = 0 TO (numinflections%-1)
 PRINT'" inflection ";count%+1;" is (in cents:"
 INPUT'"   1,-1 etc; max 49,-49) "inf%
 inf% = 50+inf%
 inflections%(count%) = inf%
 NEXT
 :
 REM function can feed similarly into inflections%()
 :
 PROCinsertinflections
 :
 ENDPROC
 :
 REM**********************************************
:
 DEF PROCinsertinflections
 :
 CLS
 repeatposit$ = "n"
IF seequery$ = "y" THEN
 PRINT'" Do you want to read these inflections into the array?"
 CASE GET$ OF
  WHEN "N","n" : PROCdisplay : REM inflections%() remains intact
  OTHERWISE
 ENDCASE
ENDIF : REM seequery$
 IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
   ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
 :
IF quickcopy$ = "y" THEN
INPUT ' " starting at note number "along%
IF along% = 0 THEN along% = 1
 along%-=1
 bars% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
 beats% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  holdbar% = bars%
  holdbeat% = beats%
PROCalterbeats
 startat% = (bars%*(10^3))+beats%
:
ELSE
:
INPUT'" Starting at bar number "bars%
IF bars% = 0 THEN
 bars% = holdbar% : beats% = holdbeat% : repeatposit$ = "y"
ENDIF
 holdbar% = bars%
IF repeatposit$ = "y" THEN
PRINT'" bar ";bars%;" beat ";beats%;"?"
PRINT" (for OK press 0, if not OK press X)"
CASE GET$ OF
 WHEN"X","x" : PROCinsertpitches
 OTHERWISE
ENDCASE
ELSE
 INPUT " beat "beats%
 holdbeat% = beats%
ENDIF
 PROCalterbeats
 startat% = (bars%*(10^3))+beats%
:
ENDIF
:
 PROCsearch(startat%)
 shunt$ = "N"
:
 FOR count% = startcell% TO (startcell%+(numinflections%-1))
 PROCcellfill(count%,voice%,999,999,999,9,999,999,99,inflections%(count%-startcell%))
 NEXT
 PROCdisplay
 ENDPROC
 :
 REM****************************************************
 :
 DEF PROCenv
 :
 temp = tempi%(brrr%)
 IF waveload$ = "done" THEN temp = temp*1.23065
 converter = 1200/(temp*960)
 dur1 = dur%/converter
 dur2 = dur1*10
 dur3 = dur2 MOD 10
 IF dur3 >= 5 THEN dur% = dur1+1 ELSE dur% = dur1
 :
 dyn1% = dyn% + 128
 :
 number% = array%(cell%(voicenum%),2,voicenum%)DIV10^5
 IF number% = 0 THEN numphases% = 1
 IF number% > 0 AND number% < 100 THEN numphases% = 2
 IF number% > 99 THEN numphases% = 3
 :
 CASE nvoices% OF
  WHEN 1 : st% = 1
  OTHERWISE st% = 2
 ENDCASE
 :
 CASE numphases% OF
  :
  WHEN 1 :
  :
  gliss1% = (array%(cell%(voicenum%),1,voicenum%)DIV10^4)MOD10^2
  gliss1% = 50 - gliss1%
  gliss1% = gliss1% * 85.5
  pitchinc = gliss1%/dur%
  :
  amp2% = (array%(cell%(voicenum%),2,voicenum%)DIV10^2)MOD10
  dyn2% = 384 + (16*amp2%)
  IF dyn2% = 512 THEN dyn2% = 511
  dynspan% = dyn2% - dyn1%
  dyninc = dynspan%/dur%
  :
  FOR loop% = 10 TO dur% STEP (dur%/32)*st%
   loud% = dyninc*loop%
   high% = pitchinc*loop%
   SOUND count%, dyn1%+loud%, pitch%+high%, 0, after%+loop%
  NEXT
  :
  WHEN 2 :
   ph1% = number% MOD 10^2
   point1% = dur%*ph1%/100
   :
  REM first phase
  gliss1% = (array%(cell%(voicenum%),1,voicenum%)DIV10^4)MOD10^2
  gliss1% = 50 - gliss1%
  gliss1% = gliss1% * 85.5
  pitchinc = gliss1%/point1%
  :
  amp2% = (array%(cell%(voicenum%),2,voicenum%)DIV10^2)MOD10
  dyn2% = 384 + (16*amp2%)
  IF dyn2% = 512 THEN dyn2% = 511
  dynspan% = dyn2% - dyn1%
  dyninc = dynspan%/point1%
  :
  FOR loop% = 10 TO point1%-10 STEP ((point1%)/32)*st%
   loud% = dyninc*loop%
   high% = pitchinc*loop%
   SOUND count%, dyn1%+loud%, pitch%+high%, 0, after%+loop%
  NEXT
  :
  REM second phase
  gliss2% = (array%(cell%(voicenum%),1,voicenum%)DIV10^6)MOD10^2
  gliss2% = 50 - gliss2%
  gliss2% = gliss2% * 85.5
  pitchinc = gliss2%/(dur%-point1%)
  :
  amp3% = (array%(cell%(voicenum%),2,voicenum%)DIV10^3)MOD10
  dyn3% = 384 + (16*amp3%)
  IF dyn3% = 512 THEN dyn2% = 511
  dynspan% = dyn3% - dyn2%
  dyninc = dynspan%/(dur%-point1%)
  :
  FOR loop% = 0 TO dur%-point1% STEP ((dur%-point1%)/32)*st%
   loud% = dyninc*loop%
   high% = pitchinc*loop%
   SOUND count%, dyn2%+loud%, pitch%+gliss1%+high%, 0, after%+point1%+loop%
  NEXT
  :
  WHEN 3 :
   ph1% = number% MOD 10^2
   point1% = dur%*ph1%/100
   ph2% = number% DIV 10^2
   point2% = dur%*ph2%/100
   :
   REM first phase
   gliss1% = (array%(cell%(voicenum%),1,voicenum%)DIV10^4)MOD10^2
   gliss1% = 50 - gliss1%
   gliss1% = gliss1% * 85.5
   pitchinc = gliss1%/point1%
   :
   amp2% = (array%(cell%(voicenum%),2,voicenum%)DIV10^2)MOD10
   dyn2% = 384 + (16*amp2%)
   IF dyn2% = 512 THEN dyn2% = 511
   dynspan% = dyn2% - dyn1%
   dyninc = dynspan%/point1%
   :
   FOR loop% = 10 TO point1%-10 STEP ((point1%)/32)*st%
   loud% = dyninc*loop%
   high% = pitchinc*loop%
   SOUND count%, dyn1%+loud%, pitch%+high%, 0, after%+loop%
   NEXT
   :
   REM second phase
   gliss2% = (array%(cell%(voicenum%),1,voicenum%)DIV10^6)MOD10^2
   gliss2% = 50 - gliss2%
   gliss2% = gliss2% * 85.5
   pitchinc = gliss2%/(point2%-point1%)
   :
   amp3% = (array%(cell%(voicenum%),2,voicenum%)DIV10^3)MOD10
   dyn3% = 384 + (16*amp3%)
   IF dyn3% = 512 THEN dyn3% = 511
   dynspan% = dyn3% - dyn2%
   dyninc = dynspan%/(point2%-point1%)
   :
   FOR loop% = 0 TO point2%-point1%-10 STEP ((point2%-point1%)/32)*st%
   loud% = dyninc*loop%
   high% = pitchinc*loop%
   SOUND count%, dyn2%+loud%, pitch%+gliss1%+high%, 0, after%+point1%+loop%
   NEXT
   :
   REM third phase
   gliss3% = (array%(cell%(voicenum%),1,voicenum%)DIV10^8)
   gliss3% = 10 - gliss3%
   gliss3% = gliss3% * 85.5
   pitchinc = gliss3%/(dur%-point2%)
   :
   amp4% = (array%(cell%(voicenum%),2,voicenum%)DIV10^4)MOD10
   dyn4% = 384 + (16*amp4%)
   IF dyn4% = 512 THEN dyn4% = 511
   dynspan% = dyn4% - dyn3%
   dyninc = dynspan%/(dur%-point2%)
   :
   FOR loop% = 0 TO dur%-point2% STEP ((dur%-point2%)/32)*st%
   loud% = dyninc*loop%
   high% = pitchinc*loop%
   SOUND count%, dyn3%+loud%, pitch%+gliss1%+gliss2%+high%, 0, after%+point2%+loop%
   NEXT
   :
   ENDCASE
   :
 ENDPROC
 :
 REM******************************************************
 :
 DEF PROCquit
 :
 CLS
 PRINT''''" Do you want to SAVE"
 PRINT" before quitting?"
 CASE GET$ OF
  WHEN "N","n" :
  REM this line and next two 'deleted' for now - IF wavefilingsystem$ = "loaded" THEN
  REM *RMKill WFS
  REM ENDIF
 *NoDir
 QUIT
  OTHERWISE
   quitnow$ = "y"
   PROCsave
 ENDCASE
 ENDPROC
 :
 REM******************************************************
 :
 DEF PROCsave
 :
 firstnaming$ = "n"
 CLS
 IF filename$ = "" THEN
 INPUT'" filename "filename$
 firstnaming$ = "y"
 DIM lastfilename$(9)
 housekeepingdimmed$ = "y"
 PROChousekeeping
 ENDIF
 IF firstnaming$ = "n" THEN
  PRINT'" as '";filename$;"'?"
  CASE GET$ OF
   WHEN "N","n" :
    INPUT'" filename "filename$
   OTHERWISE
  ENDCASE
 ENDIF
 :
 *Dir SDFS::RISCOSpi.$.CAC.Files
 :
 channel = OPENOUT filename$
 PRINT#channel, manynotes%
 PRINT#channel, numparts%
 PRINT#channel, nobars%
 PRINT#channel, startv%
 PRINT#channel, startv1%
 PRINT#channel, numbars%
 PRINT#channel, startbar%
 PRINT#channel, numvoices%
 PRINT#channel, factor%
 PRINT#channel, beatfactor%
 PRINT#channel, beams%
 PRINT#channel, longbeatsupper%
 PRINT#channel, longbeatslower%
 PRINT#channel, tempo%
 PRINT#channel, MM%
 PRINT#channel, notehead$
 PRINT#channel, longscore$
 PRINT#channel, barlines$
 PRINT#channel, staves$
 PRINT#channel, beats$
 PRINT#channel, amplitudes$
 PRINT#channel, names$
 PRINT#channel, accidentals$
 PRINT#channel, stems$
 PRINT#channel, xoption$
 PRINT#channel, durations$
 PRINT#channel, envelopes$
 PRINT#channel, glissandos$
 PRINT#channel, numwaves%
 PRINT#channel, manywaves%
 PRINT#channel, barnosoften%
 FOR c% = 0 TO (numparts%-1)
  PRINT#channel, numusedcells%(c%)
 NEXT
 FOR e% = 0 TO (numparts%-1)
  FOR d% = 0 TO 2
   FOR c% = 0 TO numusedcells%(e%)
    PRINT#channel, array%(c%,d%,e%)
   NEXT
  NEXT
 NEXT
 FOR c% = 0 TO numparts%
  FOR d% = 0 TO 2
   PRINT#channel, insts$(c%,d%)
  NEXT
 NEXT
 FOR c% = 0 TO nobars%
  FOR d% = 0 TO 3
   FOR e% = 0 TO (numparts%-1)
    PRINT#channel, disarray%(c%,d%,e%)
   NEXT
  NEXT
 NEXT
 FOR c% = 0 TO numparts%
  PRINT#channel, longbeamposn%(c%)
 NEXT
 FOR c% = 0 TO numparts%
  PRINT#channel, shortbeamposn%(c%)
 NEXT
 FOR c% = 0 TO numparts%
  PRINT#channel, shortamppos%(c%)
 NEXT
 FOR c% = 0 TO numparts%
  PRINT#channel, longamppos%(c%)
 NEXT
 FOR c% = 0 TO (numparts%-1)
  PRINT#channel, longstemdir$(c%)
 NEXT
 FOR c% = 0 TO (numparts%-1)
  PRINT#channel, shortstemdir$(c%)
 NEXT
 FOR c% = 0 TO numparts%
  PRINT#channel, waveforms$(c%)
 NEXT
 FOR c% = 0 TO numvoices%
  PRINT#channel, displayvoices%(c%)
 NEXT
 FOR c% = 0 TO 19
  PRINT#channel, wforms$(c%)
 NEXT
 FOR c% = 0 TO 8
  FOR d% = 0 TO 9
   PRINT#channel, lvdata%(c%,d%)
  NEXT
 NEXT
 FOR a% = 0 TO 47
   PRINT#channel, pitchset%(a%)
 NEXT
 FOR a% = 0 TO 47
   PRINT#channel, durset%(a%)
 NEXT
 FOR a% = 0 TO 47
   PRINT#channel, ampset%(a%)
 NEXT
 FOR a% = 0 TO 47
   PRINT#channel, glissset%(a%)
 NEXT
 FOR a% = 0 TO 47
   PRINT#channel, envset%(a%)
 NEXT
 FOR a% = 0 TO nobars%
   PRINT#channel, tempi%(a%)
 NEXT
 FOR a% = 0 TO nobars%
  FOR b% = 0 TO 1
   PRINT#channel, remarks$(a%,b%)
  NEXT
 NEXT
 :
 CLOSE#channel
 *NoDir
 :
 goproc$ = "y"
 FOR count% = 1 TO 9
  IF lastfilename$(count%) = filename$ THEN
   goproc$ = "n" : theone% = count%
  ENDIF
 NEXT
 IF goproc$ = "n" THEN
  IF theone% > 1 THEN
   PROCspecialshunt : PROCfornexttime
  ENDIF
 ENDIF
 IF goproc$ = "y" THEN
  PROCshuntlastfilename : PROCfornexttime
 ENDIF
 :
 IF quitnow$ = "y" THEN
  *NoDir
  QUIT
 ELSE
  PROCdisplay
 ENDIF
 :
 ENDPROC
 :
 REM******************************************
 :
 DEF PROCloadfile
 :
 housekeepingdimmed$ = "n"
 PROChousekeeping
 PRINT'"  The most recent files saved were "
 FOR count% = 1 TO 9
 PRINT'count%;". ";lastfilename$(count%)
 NEXT
 PRINT'"  To open one press its number, for another press 0 "
 CASE GET$ OF
  WHEN "1" : filename$ = lastfilename$(1)
  WHEN "2" : filename$ = lastfilename$(2)
  WHEN "3" : filename$ = lastfilename$(3)
  WHEN "4" : filename$ = lastfilename$(4)
  WHEN "5" : filename$ = lastfilename$(5)
  WHEN "6" : filename$ = lastfilename$(6)
  WHEN "7" : filename$ = lastfilename$(7)
  WHEN "8" : filename$ = lastfilename$(8)
  WHEN "9" : filename$ = lastfilename$(9)
  OTHERWISE
   INPUT'"  the one you want is "filename$
 ENDCASE
 :
*Dir SDFS::RISCOSpi.$.CAC.Files
 channel = OPENIN filename$
 REPEAT
  INPUT#channel, manynotes%
  INPUT#channel, numparts%
  INPUT#channel, nobars%
  instsdimmed$ = "n"
  PROCarraysetup
  INPUT#channel, startv%
  INPUT#channel, startv1%
  INPUT#channel, numbars%
  INPUT#channel, startbar%
  INPUT#channel, numvoices%
  INPUT#channel, factor%
  INPUT#channel, beatfactor%
  INPUT#channel, beams%
  INPUT#channel, longbeatsupper%
  INPUT#channel, longbeatslower%
  INPUT#channel, tempo%
  INPUT#channel, MM%
  INPUT#channel, notehead$
  INPUT#channel, longscore$
  INPUT#channel, barlines$
  INPUT#channel, staves$
  INPUT#channel, beats$
  INPUT#channel, amplitudes$
  INPUT#channel, names$
  INPUT#channel, accidentals$
  INPUT#channel, stems$
  INPUT#channel, xoption$
  INPUT#channel, durations$
  INPUT#channel, envelopes$
  INPUT#channel, glissandos$
  INPUT#channel, numwaves%
  INPUT#channel, manywaves%
  INPUT#channel, barnosoften%
  FOR c% = 0 TO (numparts%-1)
   INPUT#channel, numusedcells%(c%)
  NEXT
  FOR e% = 0 TO (numparts%-1)
   FOR d% = 0 TO 2
    FOR c% = 0 TO numusedcells%(e%)
     INPUT#channel, array%(c%,d%,e%)
    NEXT
   NEXT
  NEXT
  FOR c% = 0 TO numparts%
   FOR d% = 0 TO 2
    INPUT#channel, insts$(c%,d%)
   NEXT
  NEXT
  FOR c% = 0 TO nobars%
   FOR d% = 0 TO 3
    FOR e% = 0 TO (numparts%-1)
     INPUT#channel, disarray%(c%,d%,e%)
    NEXT
   NEXT
  NEXT
  FOR c% = 0 TO numparts%
   INPUT#channel, longbeamposn%(c%)
  NEXT
  FOR c% = 0 TO numparts%
   INPUT#channel, shortbeamposn%(c%)
  NEXT
  FOR c% = 0 TO numparts%
   INPUT#channel, shortamppos%(c%)
  NEXT
  FOR c% = 0 TO numparts%
   INPUT#channel, longamppos%(c%)
  NEXT
 FOR c% = 0 TO (numparts%-1)
  INPUT#channel, longstemdir$(c%)
  NEXT
  FOR c% = 0 TO (numparts%-1)
   INPUT#channel, shortstemdir$(c%)
  NEXT
  FOR c% = 0 TO numparts%
   INPUT#channel, waveforms$(c%)
  NEXT
 FOR c% = 0 TO numvoices%
   INPUT#channel, displayvoices%(c%)
 NEXT
 FOR c% = 0 TO 19
  INPUT#channel, wforms$(c%)
 NEXT
 FOR c% = 0 TO 8
  FOR d% = 0 TO 9
   INPUT#channel, lvdata%(c%,d%)
  NEXT
 NEXT
  FOR a% = 0 TO 47
   INPUT#channel, pitchset%(a%)
 NEXT
  FOR a% = 0 TO 47
   INPUT#channel, durset%(a%)
 NEXT
  FOR a% = 0 TO 47
   INPUT#channel, ampset%(a%)
 NEXT
  FOR a% = 0 TO 47
   INPUT#channel, glissset%(a%)
 NEXT
  FOR a% = 0 TO 47
   INPUT#channel, envset%(a%)
 NEXT
  FOR a% = 0 TO nobars%
   INPUT#channel, tempi%(a%)
 tempi%(0) = tempi%(1)
 NEXT
 FOR a% = 0 TO nobars%
  FOR b% = 0 TO 1
   INPUT#channel, remarks$(a%,b%)
  NEXT
 NEXT
 :
 holdnum% = numvoices% : holdstart% = startv%
 FOR count% = 1 TO numvoices% : holddisplay%(count%) = displayvoices%(count%) : NEXT
 :
 UNTIL EOF#channel
 CLOSE#channel
 *NoDir
 :
 alterbeatsat% = (960/beatfactor%)/8
 :
 PROCdisplay
 :
 ENDPROC
 :
 REM******************************************************
 :
 DEF PROCplaysubmenu
 :
 IF easiermenus$ = "n" THEN
 PROCwindow(20,71,60,54)
 COLOUR 63
 PRINT'"   Load waveforms             W"
 COLOUR 0
 PRINT "   Assign waveforms to voices A"
 PRINT "   Set tempo                  T"
 PRINT "   Set l.v.                   L"
 PRINT "   Beats input                B"
 PRINT "   Memory setup               M"
 PRINT "   Display pitches in colours C"
 PRINT "   Display options            D"
 PRINT "   Remarks                    R"
 PRINT "   Rename staves              S"
 PRINT "   Change a stave's clef      K"
 PRINT "   Quickplay options          Q"
 PRINT "   Set stereo positions       P"
 PRINT "   Set key response speeds    E"
 PRINT "   Tutorial                   U"
 PRINT "   Re-set parameter defaults  V"
 ELSE
 PROCwindow(20,69,60,37)
 COLOUR 63
 PRINT'"   Load waveforms             W"
 COLOUR 0
 PRINT '"   Assign waveforms to voices A"
 PRINT '"   Set tempo                  T"
 PRINT '"   Set l.v.                   L"
 PRINT '"   Beats input                B"
 PRINT '"   Memory setup               M"
 PRINT '"   Display pitches in colours C"
 PRINT '"   Display options            D"
 PRINT '"   Remarks                    R"
 PRINT '"   Rename staves              S"
 PRINT '"   Change a stave's clef      K"
 PRINT '"   Quickplay options          Q"
 PRINT '"   Set stereo positions       P"
 PRINT '"   Set key response speeds    E"
 PRINT '"   Tutorial                   U"
 PRINT '"   Re-set parameter defaults  V"
 ENDIF
 CASE GET$ OF
  WHEN "v" : CLS
   PRINT'" Amplitude                  A"
   CASE GET$ OF
    WHEN "a" :
     PRINT'" Re-set default amplitude"
     INPUT " in a batch between which voice "firstvoice%
     INPUT'" and which voice "secondvoice%
     INPUT'" And set it at which amplitude "value$
     CASE value$ OF
      WHEN "fff" : value% = 8
      WHEN "ff"  : value% = 7
      WHEN "f"   : value% = 6
      WHEN "mf"  : value% = 5
      WHEN "mp"  : value% = 4
      WHEN "p"   : value% = 3
      WHEN "pp"  : value% = 2
      WHEN "ppp" : value% = 1
      WHEN "0"   : value% = 0
     ENDCASE
     FOR count% = (firstvoice%-1) TO (secondvoice%-1)
      ampset%(count%) = value%
     NEXT
    ENDCASE
    PROCdisplay
  :
  WHEN "U","u" : PROCtutorial
  :
  WHEN "E","e" : CLS
   PRINT '" To set response time for downward "
   PRINT " copying from top stave press D "
   PRINT '" To set response time for "
   PRINT " move left/right press M "
   PRINT '" To set response time for "
   PRINT " move up/down press U "
   PRINT '" To set response time for pause "
   PRINT " after first digit input press F "
   PRINT '" To set response time for pause "
   PRINT " after second digit input press S "
   CASE GET$ OF
    WHEN "D","d" :
    CLS
    PRINT'" delay how many hundredths of a second "
    PRINT " (default is 50,";
    PRINT " currently set at ";downwardsspeed%;")"
    INPUT ' downwardsspeed%
    WHEN "M","m" :
    PRINT'" delay how many hundredths of a second "
    PRINT " (default is 25, currently set at ";horizscroll%;")"
    INPUT horizscroll%
    WHEN "U","u" :
    PRINT'" delay how many hundredths of a second "
    PRINT " (default is 25, currently set at ";vertscroll%;")"
    INPUT vertscroll%
    WHEN "F","f" :
    PRINT'" pause for how many hundredths "
    PRINT " of a second (currently ";waitafterfirst%;")"
    INPUT waitafterfirst%
    waitaftersecond% = waitafterfirst% : REM stops waiting unnecessarily for a 3rd digit
    WHEN "S","s" :
    PRINT'" pause for how many hundredths "
    PRINT " of a second (currently ";waitaftersecond%;")"
    INPUT waitaftersecond%
   ENDCASE
   PROCdisplay
  :
  WHEN "A","a" :
  PROCwindow(20,72,83,25)
   VDU 14
   PRINT'" Current assignations are "
   PRINT'" (press Ctrl-Shift to scroll down) "
   REM PRINT "  "
   FOR count% = 1 TO numparts%
    IF waveforms$(count%) <> "" THEN
     PRINT'"  voice ";count%;
     IF insts$(count%,0)<> "" THEN PRINT " (";insts$(count%,0);")";
     PRINT " - ";waveforms$(count%)
    ENDIF
   NEXT
   VDU 15
   PRINT''" Do you want to                                 "
   PRINT' "   Keep these                                 K "
   PRINT' "   Reassign                                   R "
   PRINT' "   Use WaveSynth-Beep defaults                W "
   PRINT' "   Randomly assign sustaining instruments,      "
   PRINT  "   dry instruments or drums                   S/D/M "
   PRINT' "   Assign in groups                           G "
   :
   CASE GET$ OF
    WHEN "R","r" : defaultvoices$ = "n" : PROCassignvoices : PROCdisplay
    WHEN "W","w" : defaultvoices$ = "y" : PROCassignvoices : PROCdisplay
    WHEN "K","k" : defaultvoices$ = "n" : PROCdisplay
    WHEN "S","s" : defaultvoices$ = "n" : type$ = "sustaining" : PROCrandomassign : PROCdisplay
    WHEN "M","m" : defaultvoices$ = "n" : type$ = "drums" : PROCrandomassign : PROCdisplay
    WHEN "D","d" : defaultvoices$ = "n" : PROCrandomdry : PROCdisplay
    WHEN "G","g" : defaultvoices$ = "n" : PROCgroupassign : PROCdisplay
    OTHERWISE
     PROCdisplay
   ENDCASE
  WHEN "T","t" : PROCtempo
  WHEN "L","l" : PROClv
  WHEN "W","w" : PROCloadwaveforms
  WHEN "B","b" :
   CLS : PRINT' " Typing numbers up to ";((960/beatfactor%)/8)-1
   PRINT '" should be read as macro-beats "
   PRINT'" or micro-beats? (+/-) "
   CASE GET$ OF
    WHEN "+","=" : alterbeatsat% = (960/beatfactor%)/8
    OTHERWISE
    alterbeatsat% = 0
   ENDCASE
   :
  PROCdisplay
  WHEN "M","m" :
   CLS : PRINT '" This file was set up as follows:"
   PRINT'" Number of bars - ";nobars%
   PRINT'" Notes per bar in busiest - ";manynotes%/nobars%
   PRINT'" Number of voices - ";numparts%
   PRINT'" (Press a key to continue)"
   CASE GET$ OF
    WHEN "C","c" :
    OTHERWISE
   ENDCASE
   PROCdisplay
 WHEN "C","c" :
  CLS : PRINT'" Do you want any pitches displayed in "
  PRINT " in colours? "
  CASE GET$ OF
   WHEN "Y","y" :
    PRINT'" Re-define these, or use previous "
    PRINT " settings? (R/P)"
    CASE GET$ OF
     WHEN "R","r" :
      INPUT'" How many colours "numcols%
      FOR tt% = 1 TO numcols%
       PRINT'" Colour ";tt%;" has how many pitches  "
       INPUT numredpitches%(tt%)
       FOR ttt% = 1 TO numredpitches%(tt%)
        PRINT' " Note name for pitch ";ttt%;" is ";
        COLOUR 3
        CASE GET$ OF
         WHEN "C","c" : note% = 0 : PRINT "C"
         WHEN "D","d" : note% = 1 : PRINT "D"
         WHEN "E","e" : note% = 2 : PRINT "E"
         WHEN "F","f" : note% = 3 : PRINT "F"
         WHEN "G","g" : note% = 4 : PRINT "G"
         WHEN "A","a" : note% = 5 : PRINT "A"
         WHEN "B","b" : note% = 6 : PRINT "B"
        ENDCASE
        COLOUR 0
        PRINT "               accidental ";
        COLOUR 3
        CASE GET$ OF
         WHEN "1" : accid% = 1 : PRINT "flat"
         WHEN "2" : accid% = 2 : PRINT "3/8flat"
         WHEN "3" : accid% = 3 : PRINT "1/4flat"
         WHEN "4" : accid% = 4 : PRINT "1/8flat"
         WHEN "5" : accid% = 5 : PRINT "nat"
         WHEN "6" : accid% = 6 : PRINT "1/8shrp"
         WHEN "7" : accid% = 7 : PRINT "1/4shrp"
         WHEN "8" : accid% = 8 : PRINT "3/8shrp"
         WHEN "9" : accid% = 9 : PRINT "shrp"
        ENDCASE
        COLOUR 0
        PRINT "                   octave ";
        COLOUR 3
        CASE GET$ OF
         WHEN "0" : octave% = 0 : PRINT "0"
         WHEN "1" : octave% = 1 : PRINT "1"
         WHEN "2" : octave% = 2 : PRINT "2"
         WHEN "3" : octave% = 3 : PRINT "3"
         WHEN "4" : octave% = 4 : PRINT "4"
         WHEN "5" : octave% = 5 : PRINT "5"
         WHEN "6" : octave% = 6 : PRINT "6"
         WHEN "7" : octave% = 7 : PRINT "7"
         WHEN "8" : octave% = 8 : PRINT "8"
        ENDCASE
        COLOUR 0
        redpitches%(tt%,ttt%) = (note%*100)+(accid%*10)+octave%
       NEXT
      NEXT
      redpitches$ = "y"
     OTHERWISE
      redpitches$ = "n"
      FOR count% = 0 TO 9
       IF numredpitches%(count%) <> 0 THEN redpitches$ = "y"
      NEXT
    ENDCASE
   OTHERWISE redpitches$ = "n"
  ENDCASE
 PROCdisplay
:
WHEN "D","d" : PROCdisplayoptions : PROCdisplay
WHEN "R","r" : PROCremarks : PROCdisplay
WHEN "S","s" : PROCnamestaves : PROCdisplay
WHEN "K","k" : PROCchangeclef : PROCdisplay
WHEN "Q","q" :
  CLS
  PRINT '" Quickplay (by pressing P)"
  PRINT '" how many voices downwards"
  INPUT '" from top of screen "quickplay%
  PROCdisplay
WHEN "P","p" :
  CLS
  PRINT' " (Voices are assigned to channels 1-8 "
  PRINT  "  according to the order in which "
  PRINT  "  they are typed into Play) "
  PRINT' " Set the 8 channels to stereo "
  PRINT  " positions 12344567, keep mono default, "
  PRINT  " set the 8 channels to random positions "
  PRINT  " or define channels' stereo positions "
  PRINT " (S/M/R/D) "
  CASE GET$ OF
   WHEN "S","s" :
    STEREO 1, -127
    STEREO 2, -79
    STEREO 3, -47
    STEREO 4, -15
    STEREO 5, -15
    STEREO 6, +16
    STEREO 7, +48
    STEREO 8, +80
   WHEN "M","m" :
    STEREO 1, -15
    STEREO 2, -15
    STEREO 3, -15
    STEREO 4, -15
    STEREO 5, -15
    STEREO 6, -15
    STEREO 7, -15
    STEREO 8, -15
   WHEN "D","d" :
    CLS
    PRINT '" Define positions for how many "
    INPUT " channels "numchannels%
    FOR count% = 1 TO numchannels%
     PRINT' " Channel ";count%;" is set to which "
     INPUT " stereo position of the 7 available "position%
     CASE count% OF
      WHEN 1 :
       CASE position% OF
        WHEN 1 : STEREO 1, -127
        WHEN 2 : STEREO 1, -79
        WHEN 3 : STEREO 1, -47
        WHEN 4 : STEREO 1, -15
        WHEN 5 : STEREO 1, +16
        WHEN 6 : STEREO 1, +48
        WHEN 7 : STEREO 1, +80
       ENDCASE
      WHEN 2 :
       CASE position% OF
        WHEN 1 : STEREO 2, -127
        WHEN 2 : STEREO 2, -79
        WHEN 3 : STEREO 2, -47
        WHEN 4 : STEREO 2, -15
        WHEN 5 : STEREO 2, +16
        WHEN 6 : STEREO 2, +48
        WHEN 7 : STEREO 2, +80
       ENDCASE
       WHEN 3 :
       CASE position% OF
        WHEN 1 : STEREO 3, -127
        WHEN 2 : STEREO 3, -79
        WHEN 3 : STEREO 3, -47
        WHEN 4 : STEREO 3, -15
        WHEN 5 : STEREO 3, +16
        WHEN 6 : STEREO 3, +48
        WHEN 7 : STEREO 3, +80
       ENDCASE
      WHEN 4 :
       CASE position% OF
        WHEN 1 : STEREO 4, -127
        WHEN 2 : STEREO 4, -79
        WHEN 3 : STEREO 4, -47
        WHEN 4 : STEREO 4, -15
        WHEN 5 : STEREO 4, +16
        WHEN 6 : STEREO 4, +48
        WHEN 7 : STEREO 4, +80
       ENDCASE
      WHEN 5 :
       CASE position% OF
        WHEN 1 : STEREO 5, -127
        WHEN 2 : STEREO 5, -79
        WHEN 3 : STEREO 5, -47
        WHEN 4 : STEREO 5, -15
        WHEN 5 : STEREO 5, +16
        WHEN 6 : STEREO 5, +48
        WHEN 7 : STEREO 5, +80
       ENDCASE
      WHEN 6 :
       CASE position% OF
        WHEN 1 : STEREO 6, -127
        WHEN 2 : STEREO 6, -79
        WHEN 3 : STEREO 6, -47
        WHEN 4 : STEREO 6, -15
        WHEN 5 : STEREO 6, +16
        WHEN 6 : STEREO 6, +48
        WHEN 7 : STEREO 6, +80
       ENDCASE
      WHEN 7 :
       CASE position% OF
        WHEN 1 : STEREO 7, -127
        WHEN 2 : STEREO 7, -79
        WHEN 3 : STEREO 7, -47
        WHEN 4 : STEREO 7, -15
        WHEN 5 : STEREO 7, +16
        WHEN 6 : STEREO 7, +48
        WHEN 7 : STEREO 7, +80
       ENDCASE
      WHEN 8 :
       CASE position% OF
        WHEN 1 : STEREO 8, -127
        WHEN 2 : STEREO 8, -79
        WHEN 3 : STEREO 8, -47
        WHEN 4 : STEREO 8, -15
        WHEN 5 : STEREO 8, +16
        WHEN 6 : STEREO 8, +48
        WHEN 7 : STEREO 8, +80
       ENDCASE
      ENDCASE
    NEXT
  WHEN "R","r" :
   position% = RND(7)
   CASE position% OF
    WHEN 1 : STEREO 1, -127
    WHEN 2 : STEREO 1, -79
    WHEN 3 : STEREO 1, -47
    WHEN 4 : STEREO 1, -15
    WHEN 5 : STEREO 1, +16
    WHEN 6 : STEREO 1, +48
    WHEN 7 : STEREO 1, +80
   ENDCASE
   position% = RND(7)
   CASE position% OF
    WHEN 1 : STEREO 2, -127
    WHEN 2 : STEREO 2, -79
    WHEN 3 : STEREO 2, -47
    WHEN 4 : STEREO 2, -15
    WHEN 5 : STEREO 2, +16
    WHEN 6 : STEREO 2, +48
    WHEN 7 : STEREO 2, +80
   ENDCASE
   position% = RND(7)
   CASE position% OF
    WHEN 1 : STEREO 3, -127
    WHEN 2 : STEREO 3, -79
    WHEN 3 : STEREO 3, -47
    WHEN 4 : STEREO 3, -15
    WHEN 5 : STEREO 3, +16
    WHEN 6 : STEREO 3, +48
    WHEN 7 : STEREO 3, +80
   ENDCASE
   position% = RND(7)
   CASE position% OF
    WHEN 1 : STEREO 4, -127
    WHEN 2 : STEREO 4, -79
    WHEN 3 : STEREO 4, -47
    WHEN 4 : STEREO 4, -15
    WHEN 5 : STEREO 4, +16
    WHEN 6 : STEREO 4, +48
    WHEN 7 : STEREO 4, +80
   ENDCASE
   position% = RND(7)
   CASE position% OF
    WHEN 1 : STEREO 5, -127
    WHEN 2 : STEREO 5, -79
    WHEN 3 : STEREO 5, -47
    WHEN 4 : STEREO 5, -15
    WHEN 5 : STEREO 5, +16
    WHEN 6 : STEREO 5, +48
    WHEN 7 : STEREO 5, +80
   ENDCASE
   position% = RND(7)
   CASE position% OF
    WHEN 1 : STEREO 6, -127
    WHEN 2 : STEREO 6, -79
    WHEN 3 : STEREO 6, -47
    WHEN 4 : STEREO 6, -15
    WHEN 5 : STEREO 6, +16
    WHEN 6 : STEREO 6, +48
    WHEN 7 : STEREO 6, +80
   ENDCASE
   position% = RND(7)
   CASE position% OF
    WHEN 1 : STEREO 7, -127
    WHEN 2 : STEREO 7, -79
    WHEN 3 : STEREO 7, -47
    WHEN 4 : STEREO 7, -15
    WHEN 5 : STEREO 7, +16
    WHEN 6 : STEREO 7, +48
    WHEN 7 : STEREO 7, +80
   ENDCASE
   position% = RND(7)
   CASE position% OF
    WHEN 1 : STEREO 8, -127
    WHEN 2 : STEREO 8, -79
    WHEN 3 : STEREO 8, -47
    WHEN 4 : STEREO 8, -15
    WHEN 5 : STEREO 8, +16
    WHEN 6 : STEREO 8, +48
    WHEN 7 : STEREO 8, +80
   ENDCASE
  :
  ENDCASE
  PROCdisplay
  OTHERWISE VDU 7 : PROCplaysubmenu
  ENDCASE
 :
 ENDPROC
 :
 REM*******************************************
 :
 DEF PROClv
 :
 CLS
 lvdata%() = 0
 PRINT'" How many sound channels"
 INPUT'" are to generate lv "nlv%
 IF nlv% = 0 THEN
  lvdata%() = 0
 ELSE
  FOR count% = 1 TO nlv%
  PRINT '" lv channel ";count%;" is to use"
  INPUT '" how many other channels? "numchans%
  FOR c% = 1 TO numchans%
  PRINT '" of these, channel ";c%;
  INPUT  " is channel "ch%
  lvdata%(count%,c%+1) = ch%
  NEXT
  lvdata%(count%,1) = count%
 NEXT
 ENDIF
 :
 PROCdisplay
 :
 ENDPROC
 :
 REM***********************************
 :
 DEF PROCloadwaveforms
 :
 CLS
 IF waveload$ = "done" THEN
PROCwindow(20,71,60,35) : CLS
  PRINT'" These waveforms have already been loaded"
  PRINT " (press Ctrl-Shft to scroll down)"
 VDU 14
 FOR count% = 1 TO manywaves%
 PRINT'wforms$(count%)
  NEXT
 VDU 15


  PRINT' " Do you want to load a fresh group?"
  CASE GET$ OF
   WHEN "Y","y" : PRINT' " Press M then quit, to"
    PRINT " flush present waveforms"
    CASE GET$ OF
     WHEN "M","m" : PROCawait
  ENDCASE
  OTHERWISE PROCdisplay
  ENDCASE
 ELSE
 load$ = "new"
 IF filename$ <> "" AND wforms$(1) <> "" THEN
  PROCwindow(20,71,60,45)
  PRINT'" The waveforms previously "
  PRINT" loaded for this file were"
  PRINT" (press Ctrl-Shift to scroll down)"
   VDU 14
  FOR count% = 1 TO manywaves%
 PRINT'wforms$(count%)
  NEXT
  VDU 15
  PRINT'" Do you want to reload"
  PRINT " these or choose new ones (R/N)"
  CASE GET$ OF
   WHEN "R","r" : load$ = "previous"
   OTHERWISE
  ENDCASE
 ENDIF
 :
 IF load$ = "new" THEN
:
PRINT '" load individually or from lists? (I/L) "
CASE GET$ OF
WHEN "I","i" :


  PRINT '" How many waveforms do you want to load"
  PRINT " (the maximum for this file is ";numwaves%;")"
  INPUT manywaves%
  FOR count% = 1 TO manywaves%
   PRINT '" waveform ";count%;" is "
   INPUT wform$
   wforms$(count%) = wform$
  NEXT

OTHERWISE

PRINT'" Sustaining insts A "
PRINT'" Percussion insts B "
PRINT'" Percussion insts C "
PRINT " (press A/B/C) "
CASE GET$ OF
 WHEN "A","a" :
  manywaves% = 19
   wforms$(1) = "RecorderGb"
   wforms$(2) = "PiccoloE"
   wforms$(3) = "SaxSoprnoE"
   wforms$(4) = "JapFlute"
   wforms$(5) = "SaxBbTenrE"
   wforms$(6) = "BugleC"
   wforms$(7) = "Trombone1"
   wforms$(8) = "Trumpet"
   wforms$(9) = "EngHornGb"
   wforms$(10) = "ClarinetBb"
   wforms$(11) = "ClarVibEb"
   wforms$(12) = "BassoonEb"
   wforms$(13) = "FlugelHnEb"
  wforms$(14) = "CornetEb"
  wforms$(15) = "TubaGb"
  wforms$(16) = "HiString"
  wforms$(17) = "MidStrings"
  wforms$(18) = "BassBowAb"
  wforms$(19) = "SaxEbBarC"
 WHEN "B","b" :
  manywaves% = 19
  wforms$(1) = "Harp1"
  wforms$(2) = "Piano"
  wforms$(3) = "Vibe"
  wforms$(4) = "Timpani"
  wforms$(5) = "TimpRollEb"
  wforms$(6) = "Xylophone"
  wforms$(7) = "TablaHi"
  wforms$(8) = "BDPiloMute"
  wforms$(9) = "Snare"
  wforms$(10) = "TablaHi"
  wforms$(11) = "CymRStRoll"
  wforms$(12) = "CowBell"
  wforms$(13) = "AcuBassAb1"
  wforms$(14) = "GongSoft"
  wforms$(15) = "RotoTomRev"
  wforms$(16) = "HiHat"
  wforms$(17) = "Maracas1"
  wforms$(18) = "SimmonsBD1"
  wforms$(19) = "HiHatFoot"
WHEN "C","c" :
  manywaves% = 19
   wforms$(1) = "CymSplshCa"
   wforms$(2) = "BassBowAb"
   wforms$(3) = "Bass"
   wforms$(4) = "HiHat"
   wforms$(5) = "HiHatFoot"
   wforms$(6) = "Maracas1"
   wforms$(7) = "CachichiTr"
   wforms$(8) = "BDPiloMute"
   wforms$(9) = "AcuBassAb1"
   wforms$(10) = "SimmonsBD1"
   wforms$(11) = "CymRideBel"
   wforms$(12) = "CowBell"
   wforms$(13) = "AcouBass"
  wforms$(14) = "RotoTomRev"
  wforms$(15) = "Castanets"
  wforms$(16) = "ElecTom1"
  wforms$(17) = "CymbalCrsh"
  wforms$(18) = "CymRStRoll"
  wforms$(19) = "Tomtom1"
ENDCASE
 :
 ENDCASE
 :
 ENDIF
 :
 *Dir SDFS::RISCOSpi.$.CAC.CACvar.Voices
 *RMLOAD WFS 500000
  wavefilingsystem$ = "loaded"
 :
 FOR count% = 1 TO manywaves%
  wave$ = wforms$(count%)
  CASE wave$ OF
  WHEN "BassBowAb" :
 *Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD BassBowAb
   *WINSTALL BassBowAb
  WHEN "Vibe" :
   *Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Vibe
   *WINSTALL Vibe
  WHEN "AcouBass" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD AcouBass
   *WINSTALL AcouBass
  WHEN "BugleC" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD BugleC
   *WINSTALL BugleC
  WHEN "CornetEb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD CornetEb
   *WINSTALL CornetEb
  WHEN "SaxEbBarC" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD SaxEbBarC
   *WINSTALL SaxEbBarC
  WHEN "SaxBbTenrE" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD SaxBbTenrE
   *WINSTALL SaxBbTenrE
  WHEN "BassoonEb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD BassoonEb
   *WINSTALL BassoonEb
  WHEN "ClarinetBb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD ClarinetBb
   *WINSTALL ClarinetBb
  WHEN "EngHornGb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD EngHornGb
   *WINSTALL EngHornGb
  WHEN "MandolinDb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD MandolinDb
   *WINSTALL MandolinDb
  WHEN "Piano2B" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD Piano2B
   *WINSTALL Piano2B
  WHEN "ClarVibEb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD ClarVibEb
   *WINSTALL ClarVibEb
  WHEN "GtrDobroB" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD GtrDobroB
   *WINSTALL GtrDobroB
  WHEN "RecorderGb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD RecorderGb
   *WINSTALL RecorderGb
  WHEN "FlugelHnEb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD FlugelHnEb
   *WINSTALL FlugelHnEb
  WHEN "VceMmmGb23" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations3
   *WLOAD VceMmmGb23
   *WINSTALL VceMmmGb23
  WHEN "VceMOooGb3" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations3
   *WLOAD VceMOooGb3
   *WINSTALL VceMOooGb3
  WHEN "VceFemAahC" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations3
   *WLOAD VceFemAahC
   *WINSTALL VceFemAahC
  WHEN "VceFMmmGb4" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations3
   *WLOAD VceFMmmGb4
   *WINSTALL VceFMmmGb4
  WHEN "Bass" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.SoundSynth
   *WLOAD Bass
   *WINSTALL Bass
  WHEN "ChurchBell" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.SoundSynth
   *WLOAD ChurchBell
   *WINSTALL ChurchBell
  WHEN "GuiroFast" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD GuiroFast
   *WINSTALL GuiroFast
  WHEN "Clave" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD Clave
   *WINSTALL Clave
  WHEN "CowBell" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD CowBell
   *WINSTALL CowBell
  WHEN "CymbRideHd" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD CymbRideHd
   *WINSTALL CymbRideHd
  WHEN "AcGuitar1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD AcGuitar1
   *WINSTALL AcGuitar1
  WHEN "CongaHi" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD CongaHi
   *WINSTALL CongaHi
WHEN "DrumExplo" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD DrumExplo
   *WINSTALL DrumExplo
WHEN "ElecTom1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD ElecTom1
   *WINSTALL ElecTom1
WHEN "Harp1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Harp1
   *WINSTALL Harp1
WHEN "Harpsi" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Harpsi
   *WINSTALL Harpsi
WHEN "HiString" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD HiString
   *WINSTALL HiString
WHEN "HonkyPiano" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD HonkyPiano
   *WINSTALL HonkyPiano
WHEN "JapFlute" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD JapFlute
   *WINSTALL JapFlute
WHEN "JazzOrgan" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD JazzOrgan
   *WINSTALL JazzOrgan
WHEN "MidStrings" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD MidStrings
   *WINSTALL MidStrings
WHEN "NoteArp1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD NoteArp1
   *WINSTALL NoteArp1
WHEN "SnareEcho" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD SnareEcho
   *WINSTALL SnareEcho
WHEN "TablaHi" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD TablaHi
   *WINSTALL TablaHi
WHEN "Timpani" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Timpani
   *WINSTALL Timpani
WHEN "Tomtom1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Tomtom1
   *WINSTALL Tomtom1
WHEN "Trombone1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Trombone1
   *WINSTALL Trombone1
WHEN "Trumpet" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Trumpet
   *WINSTALL Trumpet
WHEN "Xylophone" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Xylophone
   *WINSTALL Xylophone
WHEN "AcouGtr2B" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD AcouGtr2B
   *WINSTALL AcouGtr2B
WHEN "AcuBassAb1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD AcuBassAb1
   *WINSTALL AcuBassAb1
WHEN "BagPipeG" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD BagPipeG
   *WINSTALL BagPipeG
WHEN "BanjoChdBb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD BanjoChdBb
   *WINSTALL BanjoChdBb
WHEN "BazookiE" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD BazookiE
   *WINSTALL BazookiE
WHEN "BellC" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD BellC
   *WINSTALL BellC
WHEN "BrassEns1B" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD BrassEns1B
   *WINSTALL BrassEns1B
WHEN "ClavichdBb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD ClavichdBb
   *WINSTALL ClavichdBb
WHEN "ClavinetBb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD ClavinetBb
   *WINSTALL ClavinetBb
WHEN "CornetEb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD CornetEb
   *WINSTALL CornetEb
WHEN "EnsWodAb45" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD EnsWodAb45
   *WINSTALL EnsWodAb45
WHEN "EnsWodGb12" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD EnsWodGb12
   *WINSTALL EnsWodGb12
WHEN "Glock2Ab5" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD Glock2Ab5
   *WINSTALL Glock2Ab5
WHEN "GtMelobarC" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD GtMelobarC
   *WINSTALL GtMelobarC
WHEN "GtWashbnBb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD GtWashbnBb
   *WINSTALL GtWashbnBb
WHEN "HarmonicaE" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD HarmonicaE
   *WINSTALL HarmonicaE
WHEN "Jew'sHarpA" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD Jew'sHarpA
   *WINSTALL Jew'sHarpA
WHEN "MusetteB" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD MusetteB
   *WINSTALL MusetteB
WHEN "OboeGb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD OboeGb
   *WINSTALL OboeGb
WHEN "OrchHit2B" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD OrchHit2B
   *WINSTALL OrchHit2B
WHEN "OrcSusBb23" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD OrcSusBb23
   *WINSTALL OrcSusBb23
WHEN "PiccoloE" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD PiccoloE
   *WINSTALL PiccoloE
WHEN "SaxSoprnoE" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD SaxSoprnoE
   *WINSTALL SaxSoprnoE
WHEN "StrngThkBb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD StrngThkBb
   *WINSTALL StrngThkBb
WHEN "TubaGb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations2
   *WLOAD TubaGb
   *WINSTALL TubaGb
WHEN "BassDrum" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.SoundSynth
   *WLOAD BassDrum
   *WINSTALL BassDrum
WHEN "HiHat" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.SoundSynth
   *WLOAD HiHat
   *WINSTALL HiHat
WHEN "OrcHit" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.SoundSynth
   *WLOAD OrcHit
   *WINSTALL OrcHit
WHEN "Piano" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.SoundSynth
   *WLOAD Piano
   *WINSTALL Piano
WHEN "Sax" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.SoundSynth
   *WLOAD Sax
   *WINSTALL Sax
WHEN "Snare" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.SoundSynth
   *WLOAD Snare
   *WINSTALL Snare
WHEN "Choir1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Choir1
   *WINSTALL Choir1
WHEN "ChurOrgan" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD ChurOrgan
   *WINSTALL ChurOrgan
WHEN "Opera" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD Opera
   *WINSTALL Opera
WHEN "OrchChoir" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD OrchChoir
   *WINSTALL OrchChoir
WHEN "OrganHit" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations1
   *WLOAD OrganHit
   *WINSTALL OrganHit
WHEN "AgogoAfric" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD AgogoAfric
   *WINSTALL AgogoAfric
WHEN "AgogoBrazi" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD AgogoBrazi
   *WINSTALL AgogoBrazi
WHEN "AgogoWood" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD AgogoWood
   *WINSTALL AgogoWood
WHEN "BDGatedRev" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD BDGatedRev
   *WINSTALL BDGatedRev
WHEN "BDMarching" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD BDMarching
   *WINSTALL BDMarching
WHEN "BDPiloMute" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD BDPiloMute
   *WINSTALL BDPiloMute
WHEN "Cabasa" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD Cabasa
   *WINSTALL Cabasa
WHEN "Cachichi1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD Cachichi1
   *WINSTALL Cachichi1
WHEN "CachichiTr" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD CachichiTr
   *WINSTALL CachichiTr
WHEN "Castanets" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD Castanets
   *WINSTALL Castanets
WHEN "CongaMid" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD CongaMid
   *WINSTALL CongaMid
WHEN "CongaSmCl" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD CongaSmCl
   *WINSTALL CongaSmCl
WHEN "CymbalCrsh" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD CymbalCrsh
   *WINSTALL CymbalCrsh
WHEN "CymRideBel" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD CymRideBel
   *WINSTALL CymRideBel
WHEN "CymRStRoll" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD CymRStRoll
   *WINSTALL CymRStRoll
WHEN "CymSplshCa" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD CymSplshCa
   *WINSTALL CymSplshCa
WHEN "Flexitone" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD Flexitone
   *WINSTALL Flexitone
WHEN "GongSoft" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD GongSoft
   *WINSTALL GongSoft
WHEN "Gonza1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD Gonza1
   *WINSTALL Gonza1
WHEN "GuiroSlow" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD GuiroSlow
   *WINSTALL GuiroSlow
WHEN "HandClaps" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD HandClaps
   *WINSTALL HandClaps
WHEN "HiHatFoot" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD HiHatFoot
   *WINSTALL HiHatFoot
WHEN "Maracas1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD Maracas1
   *WINSTALL Maracas1
WHEN "Ratchet" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD Ratchet
   *WINSTALL Ratchet
WHEN "RotoTomRev" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD RotoTomRev
   *WINSTALL RotoTomRev
WHEN "SimmonsBD1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD SimmonsBD1
   *WINSTALL SimmonsBD1
WHEN "SimmonsSn1" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD SimmonsSn1
   *WINSTALL SimmonsSn1
WHEN "SuperGong" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD SuperGong
   *WINSTALL SuperGong
WHEN "SynTom" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD SynTom
   *WINSTALL SynTom
WHEN "TimpCresBb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD TimpCresBb
   *WINSTALL TimpCresBb
WHEN "TimpLowBb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD TimpLowBb
   *WINSTALL TimpLowBb
WHEN "TimpRollEb" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD TimpRollEb
   *WINSTALL TimpRollEb
WHEN "TomRoll" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD TomRoll
   *WINSTALL TomRoll
WHEN "ToyHooter" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD ToyHooter
   *WINSTALL ToyHooter
WHEN "ToyWhistle" :
*Dir SDFS::RISCOSpi.$.CAC.CACvar.Creations.Creations6
   *WLOAD ToyWhistle
   *WINSTALL ToyWhistle
  OTHERWISE VDU 7 : PRINT''" !!! ";wave$;" not loaded !!!"
  PRINT'" Press C to continue loading"
  CASE GET$ OF
   WHEN"C","c" :
  ENDCASE
 ENDCASE
 NEXT
 REM waveload$ = "done" !! remove REM if loading waveforms reinstated
 ENDIF
 *NoDir
 PROCdisplay
 ENDPROC
 :
 REM*********************************************
 :
 DEF PROCtempo
 :
 warning$ = "y"
 CLS
 PRINT'" Tempo to start at which bar "
 INPUT' " (for 1 type 0)"sbar%
 PRINT'" and last until which bar "
 INPUT' " (for end type 0) "ebar%
 IF ebar% = 0 THEN ebar% = nobars%
 INPUT'" Tempo per bar is "MM%
:
REM convert durations to new tempo
FOR count% = 0 TO numparts%-1
  FOR counter% = 0 TO numusedcells%(count%)
    bar% = array%(counter%,0,count%)DIV10^6
    IF bar% >= sbar% AND bar% <= ebar% THEN
      oldtempo% = tempi%(bar%)
      dur% = (array%(counter%,1,count%)DIV10)MOD10^3
      converter = oldtempo%/MM%
      dur = dur% * converter
      fraction = ((dur*10)DIV1)MOD10
      IF fraction>4 THEN dur% = dur+1 ELSE dur% = dur
       IF dur% > 999 THEN
        dur% = 998 : REM only 3 array cells available

        IF warning$ = "y" THEN
        VDU 7
        CLS
        PRINT'" This tempo change has resulted in some "
        PRINT " voices, starting with voice ";count%+1;", being "
        PRINT " given a duration which will now be "
        PRINT " permanently too short (max = 50 secs). "
        PRINT'" If this is okay simply continue, "
        PRINT " otherwise now QUIT and reload the file. "
        PRINT'" (to continue press a key - NOT Esc)"
        CASE GET$ OF
         WHEN "c" : warning$ = "n"
         OTHERWISE warning$ = "n"
        ENDCASE
        ENDIF

       ENDIF
      part1% = (array%(counter%,1,count%)DIV10^4)*10^4
      part2% = dur% * 10
      part3% = array%(counter%,1,count%)MOD10
      array%(counter%,1,count%) = part1% + part2% + part3%
    ENDIF
  NEXT
NEXT
:
 FOR count% = sbar% TO ebar%
  tempi%(count%) = MM%
 NEXT
 IF sbar% = 1 THEN tempi%(0) = MM% : REM anticipates a bug when bars 1 - 1 PLAYed
:
PROCdisplay
 :
 ENDPROC
 :
 REM************************************************
 :
 DEF PROCerror
 :
CASE errorbeforedisplay$ OF
 WHEN "y":
  CLS
  REPORT
  PRINT " at line ";ERL
  PRINT '" To continue press Q to quit"
  PRINT '" then allocate more memory in "
  PRINT '" Tasks before starting CAC "
  CASE GET$ OF
   WHEN "Q","q" : QUIT
  ENDCASE
 WHEN "debug" :
  PROCwindow(20,69,60,54)
  REPORT
  PRINT " at line ";ERL
  PRINT'" To continue press a key"
  PRINT'" or to quit press Q "
  CASE GET$ OF
   WHEN "Q","q": QUIT
   OTHERWISE
    PROCdisplay
  ENDCASE
OTHERWISE
 PROCdisplay
ENDCASE
:
ENDPROC
 :
 REM*************************************************
 :
 DEF PROCtobegin
 :
 PRINT''''" Open a new file or an existing one? (N/E)"
 CASE GET$ OF
  WHEN "N","n" : PROCprearraysetup : PROCarraysetup
   alterbeatsat% = (960/beatfactor%)/8 : PROCdisplay
  WHEN "E","e" : PROCloadfile
  OTHERWISE VDU 7 : PROCtobegin
 ENDCASE
 :
 ENDPROC
 :
 REM************************************************
 :
 DEF PROCfunctionreception
 :
 IF easiermenus$ = "n" THEN
 PROCwindow(20,69,60,54)
 CLS : OFF
 :
 PRINT'" Accel/rit                     A"
 PRINT " Layered attacks               L"
 PRINT " Pitch string                  P"
 PRINT " Pitch string 2                S"
 PRINT " Pitch string 3                N"
 PRINT " Pitch string 4 (trill/trem)   T"
 PRINT " pitch string 5 (pattern)      R"
 PRINT " pitch string 6 (equal steps)  C"
 PRINT " Interval string               I"
 PRINT " Distort                       D"
 PRINT " Slave voice                   V"
 PRINT " Double-stop                   B"
 ELSE
PROCwindow(20,69,60,42)
 CLS : OFF
 :
 PRINT'" Accel/rit                     A"
 PRINT '" Layered attacks               L"
 PRINT '" Pitch string                  P"
 PRINT '" Pitch string 2                S"
 PRINT '" Pitch string 3                N"
 PRINT '" Pitch string 4 (trill/trem)   T"
 PRINT '" pitch string 5 (pattern)      R"
 PRINT '" pitch string 6 (equal steps)  C"
 PRINT '" Interval string               I"
 PRINT '" Distort                       D"
 PRINT '" Slave voice                   V"
 PRINT '" Double-stop                   B"
 ENDIF
 CASE GET$ OF
  WHEN "A","a" : PROCfunctionprelude
  WHEN "L","l" : PROCprelayeredattacks
  WHEN "P","p" : PROCpitchstring
  WHEN "S","s" : PROCpitchstring2
  WHEN "N","n" : PROCpitchstring3
  WHEN "T","t" : PROCpitchstring4
  WHEN "R","r" : PROCpitchstring5
  WHEN "C","c" : PROCpitchstring6
  WHEN "I","i" : PROCpreintervalstring
  WHEN "D","d" : distort$ = "ON" : CLS
   IF easiermenus$ = "n" THEN
    PROCwindow(20,69,60,54)
    CLS : OFF
   PRINT''" Distort"
   PRINT'" ATTACKS          A"
   PRINT " PITCHES          P"
   PRINT " DURATIONS        D"
   PRINT " AMPLITUDES       M"
   PRINT " ENVELOPES        E"
   PRINT " INFLECTIONS      I"
   ELSE
   PROCwindow(20,69,60,42)
   CLS : OFF
   PRINT''" Distort"
   PRINT'" ATTACKS          A"
   PRINT' " PITCHES          P"
   PRINT '" DURATIONS        D"
   PRINT '" AMPLITUDES       M"
   PRINT '" ENVELOPES        E"
   PRINT '" INFLECTIONS      I"
   ENDIF
   :
   CASE GET$ OF
    WHEN "A","a" : distortpara$ = "attacks"
    WHEN "P","p" : distortpara$ = "pitches"
    WHEN "D","d" : distortpara$ = "durations"
    WHEN "M","m" : distortpara$ = "amplitudes"
    WHEN "E","e" : distortpara$ = "envelopes"
    WHEN "I","i" : distortpara$ = "inflections"
   OTHERWISE VDU 7 : PROCfunctionreception
   ENDCASE
   PROCcopy
  WHEN "V","v" : quickslave$ = "n" : PROCslave
  WHEN "B","b" : PROCdoublestop
  WHEN "E", "e" : PROCconvertoldenvelopes
  WHEN "O", "o" : PROCroguenotes
 OTHERWISE VDU 7 : PROCfunctionreception
 ENDCASE
 ON
 :
 ENDPROC
 :
 REM**********************************************
 :
 DEF PROCprelayeredattacks
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,69,70,55) ELSE PROCwindow(20,69,70,42)
 :
 PRINT'" Re-run current settings, or edit current settings,"
 PRINT" or create new ones, or load a file? (R/E/N/F)"
 CASE GET$ OF
  WHEN "R","r" : PROClayeredattacks
  WHEN "E","e" : PROCeditlayers
  WHEN "F","f" : PROCloadlayers :PROCeditlayers
  OTHERWISE
 filenamelyr$ = ""
 :
 chanceoflayer%(1) = 1 : numlayersections% = 1 : numlayerOKsects%() = 0
 :
 INPUT'" Total duration is how many bars "bars%
 INPUT'" and how many beats "beats%
 PROCalterbeats : totallength% = (bars%*960)+beats%
 PRINT''" LAYERS -"
 INPUT'" How many layers "numlayers%
 PRINT'" Are the layers to appear equally frequently,"
 PRINT " or in certain proportions (E/P) "
 :
 CASE GET$ OF
 :
  WHEN "P","p" :
   PRINT'" Piece is divided into how many sections"
  INPUT  " of different contribution-proportions "numlayersections%
  :
  IF numlayersections% > 1 THEN
   :
   FOR count% = 2 TO numlayersections%
    PRINT'" Section ";count%;" starts at beat number "
    INPUT beats%
    PROCalterbeats : startoflayersection%(count%) = beats%
   NEXT
  ENDIF
  :
  FOR count% = 1 TO numlayersections%
   FOR count1% = 1 TO numlayers%
    PRINT '"In section ";count%;", layer ";count1%;" has "
    PRINT  "how many proportions?"
    INPUT shareoflayers%(count%,count1%)
   NEXT
  NEXT
  :
  OTHERWISE shareoflayers%() = 1
 ENDCASE
 :
 PRINT''" Are number of attacks or unit durations to be"
 PRINT  " divided into sections or appearance numbers?"
 CASE GET$ OF
  WHEN "Y","y" : bysections$ = "y"
  OTHERWISE bysections$ = "n"
 ENDCASE
 PRINT'" Are unit durations in any layers to be multiplied?"
 CASE GET$ OF
  WHEN "Y","y" : tomultiply$ = "y"
  OTHERWISE tomultiply$ = "n"
 ENDCASE
 PRINT'" Are the occurance of layers to be controlled?"
 CASE GET$ OF
  WHEN "Y","y" : tooccur$ = "y"
  OTHERWISE tooccur$ = "n"
 ENDCASE
 PRINT'" Does the number of attacks ever exceed 1?"
 CASE GET$ OF
  WHEN "Y","y" : exceed1$ = "y"
  OTHERWISE exceed1$ = "n"
 ENDCASE
 :
 FOR count% = 1 TO numlayers%
 :
 PRINT''" NUMBER OF ATTACKS -"
 :
 IF bysections$ = "y" THEN
  PRINT'" In layer ";count%;" are the number of attacks controlled"
  PRINT " by sections or by appearance number (S/A)"
  CASE GET$ OF
   WHEN "S","s" :
    attackscontrol$(count%) = "S"
    INPUT'" How many sections "numattackssections%(count%)
   IF numattackssections%(count%) > 1 THEN
    FOR count1% = 2 TO numattackssections%(count%)
     PRINT'" (layer ";count%;") section ";count1%;" starts at beat"
     INPUT beats%
     PROCalterbeats : startofattackssection%(count%,count1%)  = beats%
    NEXT
   ENDIF
    :
   IF exceed1$ = "y" THEN
    FOR count1% = 1 TO numattackssections%(count%)
     PRINT'" In layer ";count%;", section ";count1%;" the number"
     PRINT" of attacks varies between..."
     INPUT numattax%(count%,count1%,0)
     INPUT" and..."numattax%(count%,count1%,1)
    NEXT
   ELSE numattax%() = 1
   ENDIF
    :
   WHEN "A","a" :
   attackscontrol$(count%) = "A"
   INPUT'" How many 'sections' of appearances "numattackssections1%(count%)
   IF numattackssections1%(count%) > 1 THEN
    FOR count1% = 2 TO numattackssections1%(count%)
     PRINT'" (layer ";count%;") section ";count1%;" starts at appearance "
     INPUT startofattackssection1%(count%,count1%)
    NEXT
   ENDIF
   :
  IF exceed1$ = "y" THEN
   FOR count1% = 1 TO numattackssections1%(count%)
    PRINT'" In layer ";count%;", section ";count1%;" the number"
    PRINT" of attacks varies between..."
    INPUT numattax1%(count%,count1%,0)
    INPUT" and... "numattax1%(count%,count1%,1)
   NEXT
  ELSE numattax1%() = 1
  ENDIF
  ENDCASE
  :
 ELSE
  attackscontrol$(count%) = "S" : numattackssections%(count%) = 1
  IF exceed1$ = "y" THEN
  PRINT'" In layer ";count%;" the number"
  PRINT" of attacks varies between   "
  INPUT numattax%(count%,1,0)
  INPUT" and..."numattax%(count%,1,1)
  ELSE numattax%() = 1
  ENDIF
 ENDIF
 :
 PRINT''" DURATIONS"
 :
 IF bysections$ = "y" THEN
 :
 PRINT'" In layer ";count%;" are the unit durations controlled"
 PRINT" by sections or by appearance number (S/A)"
 CASE GET$ OF
  WHEN "S","s" :
   durationscontrol$(count%) = "S"
   INPUT'" How many sections "numdurationssections%(count%)
   IF numdurationssections%(count%) > 1 THEN
    FOR count1% = 2 TO numdurationssections%(count%)
     PRINT'" (layer ";count%;") section ";count1%;" starts at beat "
     INPUT beats%
     PROCalterbeats : startofdurationssection%(count%,count1%)   = beats%
    NEXT
   ENDIF
   :
   FOR count1% = 1 TO numdurationssections%(count%)
    PRINT'" In layer ";count%;", section ";count1%;" the unit duration is"
    INPUT beats%
   PROCalterbeats : doorations%(count%,count1%) = beats%
   NEXT
 :
  WHEN "A","a" :
   durationscontrol$(count%) = "A"
   INPUT'" How many 'sections' "numdurationssections1%(count%)
   IF numdurationssections1%(count%) > 1 THEN
    FOR count1% = 2 TO numdurationssections1%(count%)
     PRINT'" (layer ";count%;") section ";count1%;" starts at appearance "
     INPUT startofdurationssection1%(count%,count1%)
    NEXT
   ENDIF
  FOR count1% = 1 TO numdurationssections1%(count%)
   PRINT'" In layer ";count%;", section ";count1%;" the unit duration is "
   INPUT beats%
   PROCalterbeats : doorations1%(count%,count1%) = beats%
  NEXT
 ENDCASE
 :
 ELSE durationscontrol$(count%) = "S" : numdurationssections%(count%) = 1
  PRINT'" In layer ";count%;" the unit duration is"
  INPUT beats%
  PROCalterbeats : doorations%(count%,1) = beats%
 ENDIF
 :
 IF tomultiply$ = "y" THEN
 :
 PRINT'" Do you want the unit duration to be multiplied"
 PRINT " by a given series of values (Y/N) "
 CASE GET$ OF
  WHEN "Y","y" :
   multiplier$(count%) = "Y"
   PRINT'" starting fresh at each appearance or irrespective (F/I) "
   CASE GET$ OF
    WHEN "F","f" :
    multipliermode$(count%) = "F"
   OTHERWISE multipliermode$(count%) = "I"
   ENDCASE
  :
  PRINT'" How many values "
  INPUT numvalues%(count%)
  FOR count1% = 1 TO numvalues%(count%)
   PRINT'" value ";count1%;" is "
   INPUT values(count%,count1%)
   NEXT
  OTHERWISE multiplier$(count%) = "N"
  ENDCASE
 :
 ELSE multiplier$(count%) = "N"
 ENDIF
 :
 IF tooccur$ = "y" THEN
 :
 PRINT'" Do you want this layer to reoccur according"
 PRINT " to minimum and maximum intervals (eg to"
 PRINT " control phrase-lengths)?"
 CASE GET$ OF
  WHEN "Y","y" :
   INPUT'" How many sections of this "numlayerOKsects%(count%)
   FOR count1% = 1 TO numlayerOKsects%(count%)
    IF numlayerOKsects%(count%) > 1 THEN
     PRINT'" section ";count1%;" begins at beat "
     INPUT beats%
     PROCalterbeats : x% = beats%
    ELSE x% = 0
    ENDIF
    PRINT'" in this section the layer should NOT reoccur"
    PRINT" until at least how many beats from the"
    PRINT" end of its previous occurence?"
    INPUT beats%
    PROCalterbeats : y% = beats%
    PRINT'" but SHOULD be made to reoccur after how "
    PRINT" many beats from the end of its previous"
    PRINT" occurence?"
    INPUT beats%
    PROCalterbeats : z% = beats%
    layersOK%(count%,count1%,0) = x%
    layersOK%(count%,count1%,1) = y%
    layersOK%(count%,count1%,2) = z%
   NEXT
  OTHERWISE
 ENDCASE
 :
 ENDIF
 :
 NEXT
 :
 ENDCASE
 :
 PROClayeredattacks
 :
 ENDPROC
 :
 REM**************************************************
 :
 DEF PROClayeredattacks
 :
 REM line below to come BEFORE the loop
 cellsused% = 0 : attacks1%() = 0 : layer% = 0 : appearances%() = 0
 valuescounter%() = 1 : layerends%() = 0
 :
 REPEAT
 REM WHICH LAYER (loop starts here)
 layer1% = layer%
 layerends%(layer1%) = attacks1%(cellsused%)
 :
 REM fill OKtouselayers%() according to which section you're in
 :
 FOR count% = 1 TO numlayers%
  IF numlayerOKsects%(count%) > 0 THEN
   FOR counter% = 1 TO numlayerOKsects%(count%)
    IF attacks1%(cellsused%) >= layersOK%(count%,counter%,0) THEN
     OKtouselayers%(count%,0) = layerends%(count%) + layersOK%(count%,counter%,1)
     OKtouselayers%(count%,1) = layerends%(count%) + layersOK%(count%,counter%,2)
    ENDIF
   NEXT
  ENDIF
 NEXT
 :
 REM use any layers due
 FOR count% = 1 TO numlayers%
  IF numlayerOKsects%(count%) > 0 THEN
   IF attacks1%(cellsused%) >= OKtouselayers%(count%,1) THEN layer% = count%
  ENDIF
 NEXT
 :
 IF layer1% = layer% THEN
 :
 REPEAT
 :
 REM fill layershare%() according to which section you're in
 FOR count% = 1 TO numlayersections%
 :
  IF attacks1%(cellsused%) >= startoflayersection%(count%) THEN
   FOR count1% = 1 TO numlayers%
    layershare%(count1%) = shareoflayers%(count%,count1%)
   NEXT
  ENDIF
 NEXT
 :
 FOR count% = 1 TO numlayers%
  chanceoflayer%(count%+1) = chanceoflayer%(count%)+layershare%(count%)
 NEXT
 x% = RND((chanceoflayer%(numlayers%+1))-1)
 FOR count% = 1 TO numlayers%
  IF x% >= chanceoflayer%(count%) THEN layer% = count%
 NEXT
 :
 REM exclude layers coming too soon
 IF numlayerOKsects%(layer%) > 0 THEN
  IF attacks1%(cellsused%) < OKtouselayers%(layer%,0) THEN layerOK$ = "n" ELSE layerOK$ = "y"
 ELSE layerOK$ = "y"
 ENDIF
 UNTIL layer% <> layer1% AND layerOK$ = "y"
 :
 ENDIF
 appearances%(layer%) += 1
 :
 REM NUMBER OF ATTACKS
 IF attackscontrol$(layer%) = "S" THEN
  FOR count% = 1 TO numattackssections%(layer%)
   IF attacks1%(cellsused%) >= startofattackssection%(layer%,count%) THEN
    a% = numattax%(layer%,count%,0) : b% = numattax%(layer%,count%,1)
   IF (b%-a%) = 0 THEN
    noattax% = 1
   ELSE
    noattax% = RND((b%-a%)+1)
   ENDIF
   noattax% += (a%-1)
   ENDIF
  NEXT
 ELSE
  FOR count% = 1 TO numattackssections1%(layer%)
   IF appearances%(layer%) >= startofattackssection1%(layer%,count%) THEN
    a% = numattax1%(layer%,count%,0) : b% = numattax1%(layer%,count%,1)
   IF (b%-a%) = 0 THEN
    noattax% = 1
   ELSE
    noattax% = RND((b%-a%)+1)
   ENDIF
   noattax% += (a%-1)
   ENDIF
  NEXT
 ENDIF
 :
 IF durationscontrol$(layer%) = "S" THEN
  FOR count% = 1 TO numdurationssections%(layer%)
   IF attacks1%(cellsused%) >= startofdurationssection%(layer%,count%) THEN
    duration% = doorations%(layer%,count%)
   ENDIF
  NEXT
 ELSE
  FOR count% = 1 TO numdurationssections1%(layer%)
   IF appearances%(layer%) >= startofdurationssection1%(layer%,count%) THEN
    duration% = doorations1%(layer%,count%)
   ENDIF
  NEXT
 ENDIF
 :
 IF multiplier$(layer%) = "N" THEN
  FOR count% = 1 TO noattax%
   attacks1%(cellsused%+1) = attacks1%(cellsused%)+duration%
   cellsused% += 1
  NEXT
 ELSE
  IF multipliermode$(layer%) = "F" THEN
   FOR count% = 1 TO noattax%
    attacks1%(cellsused%+1)=attacks1%(cellsused%)+(duration%*values(layer%,count%))
    cellsused% += 1
   NEXT
  ELSE
   FOR count% = 1 TO noattax%
    attacks1%(cellsused%+1)=attacks1%(cellsused%)+(duration%*values(layer%,valuescounter%(layer%)))
    cellsused% += 1
    valuescounter%(layer%) += 1
    IF valuescounter%(layer%) > numvalues%(layer%) THEN valuescounter%(layer%) = 1
   NEXT
  ENDIF
 ENDIF
 :
 UNTIL attacks1%(cellsused%) >= totallength%
 manyattacks% = cellsused%+1
 :
 PRINT'" Do you want to save these settings?"
 CASE GET$ OF
  WHEN "Y","y" : PROCsavelayers
  OTHERWISE
 ENDCASE
 :
 method$ = "raw" : PROCinsertattacks
 :
 ENDPROC
 :
 REM*********************************************************
 :
 DEF PROCconvertsamplenote
 :
 pitchclass% = samplenote% DIV 100
 CASE pitchclass% OF
  WHEN 0 : eighthtone% = 1
  WHEN 1 : eighthtone% = 9
  WHEN 2 : eighthtone% = 17
  WHEN 3 : eighthtone% = 21
  WHEN 4 : eighthtone% = 29
  WHEN 5 : eighthtone% = 37
  WHEN 6 : eighthtone% = 45
 ENDCASE
 octave% = samplenote% MOD 10
 eighthtone% += (octave%*48)
 accidental% = ((samplenote% MOD 100)DIV10)-1
 eighthtone% += accidental%
 samplenote% = eighthtone%
 ENDPROC
 :
 REM*******************************************
 :
 DEF PROCconvertsimplenote
 :
 IF simplenote% > 2 THEN oct% = 0
 IF simplenote% > 50 THEN oct% = 1
 IF simplenote% > 98 THEN oct% = 2
 IF simplenote% > 146 THEN oct% = 3
 IF simplenote% > 194 THEN oct% = 4
 IF simplenote% > 242 THEN oct% = 5
 IF simplenote% > 290 THEN oct% = 6
 IF simplenote% > 338 THEN oct% = 7
 IF simplenote% > 386 THEN oct% = 8
 :
 WHILE simplenote% > 50
  simplenote% -= 48
 ENDWHILE
 :
 CASE simplenote% OF
  WHEN 3 : pitch% = 3
  WHEN 4 : pitch% = 4
  WHEN 5 : pitch% = 5
  WHEN 6 : pitch% = 6
  WHEN 7 : pitch% = 7
  WHEN 8 : pitch% = 8
  WHEN 9 : pitch% = 11
  WHEN 10 : pitch% = 12
  WHEN 11 : pitch% = 13
  WHEN 12 : pitch% = 14
  WHEN 13 : pitch% = 15
  WHEN 14 : pitch% = 16
  WHEN 15 : pitch% = 17
  WHEN 16 : pitch% = 18
  WHEN 17 : pitch% = 21
  WHEN 18 : pitch% = 22
  WHEN 19 : pitch% = 23
  WHEN 20 : pitch% = 24
  WHEN 21 : pitch% = 25
  WHEN 22 : pitch% = 26
  WHEN 23 : pitch% = 27
  WHEN 24 : pitch% = 34
  WHEN 25 : pitch% = 35
  WHEN 26 : pitch% = 36
  WHEN 27 : pitch% = 37
  WHEN 28 : pitch% = 38
  WHEN 29 : pitch% = 39
  WHEN 30 : pitch% = 42
  WHEN 31 : pitch% = 43
  WHEN 32 : pitch% = 44
  WHEN 33 : pitch% = 45
  WHEN 34 : pitch% = 46
  WHEN 35 : pitch% = 47
  WHEN 36 : pitch% = 48
  WHEN 37 : pitch% = 51
  WHEN 38 : pitch% = 52
  WHEN 39 : pitch% = 53
  WHEN 40 : pitch% = 54
  WHEN 41 : pitch% = 55
  WHEN 42 : pitch% = 56
  WHEN 43 : pitch% = 57
  WHEN 44 : pitch% = 58
  WHEN 45 : pitch% = 61
  WHEN 46 : pitch% = 62
  WHEN 47 : pitch% = 63
  WHEN 48 : pitch% = 64
  WHEN 49 : pitch% = 65
  WHEN 50 : pitch% = 66
 ENDCASE
 :
 simplenote% = (pitch%*10)+oct%
 ENDPROC
 :
 REM**************************************
 :
 :
 DEF PROCpitchstring
 :
 PROCwindow(20,25,70,35)
 :
 :
 PRINT'" Create a new pitch string or edit the"
 PRINT " current one, or load a file (N/E/F)"
 CASE GET$ OF
  WHEN "E","e" : loadstring$ = "n" :PROCeditpitchstring
  WHEN "F","f" : loadstring$ = "y" :PROCeditpitchstring
  OTHERWISE
 ENDCASE
 :
 filenamestg$ = ""
 contoursequences%() = 0
 transpositionsequences%() = 0
 octavesequences%() = 0
 PRINT'" Total number of notes in the"
 INPUT " pitch string (inc. sample) "numpitches%
 PRINT'" Is the grid semi, quarter or eighth-tone (S/Q/E) "
 PRINT'" (0 = semi) "
 CASE GET$ OF
  WHEN "S","s" : grid$ = "s"
  WHEN "Q","q" : grid$ = "q"
  WHEN "E","e" : grid$ = "e"
  OTHERWISE grid$ = "s"
 ENDCASE
 CLS
 :
 PRINT'" SAMPLE "
 INPUT'" How many notes in the sample? "samplesize%
 FOR count% = 1 TO samplesize%
  PRINT'" note ";count%;" is pitchclass ";
 COLOUR 3
 CASE GET$ OF
  WHEN "C","c" : samplenote% = 0 : PRINT "C"
  WHEN "D","d" : samplenote% = 1 : PRINT "D"
  WHEN "E","e" : samplenote% = 2 : PRINT "E"
  WHEN "F","f" : samplenote% = 3 : PRINT "F"
  WHEN "G","g" : samplenote% = 4 : PRINT "G"
  WHEN "A","a" : samplenote% = 5 : PRINT "A"
  WHEN "B","b" : samplenote% = 6 : PRINT "B"
 ENDCASE
 samplenote% = samplenote%*100
 COLOUR 0
 PRINT "           accidental ";
 COLOUR 3
 CASE GET$ OF
  WHEN "1" : samplenote% += 10 : PRINT "flat"
  WHEN "2" : samplenote% += 20 : PRINT "3/8 flat"
  WHEN "3" : samplenote% += 30 : PRINT "1/4 flat"
  WHEN "4" : samplenote% += 40 : PRINT "1/8 flat"
  WHEN "5" : samplenote% += 50 : PRINT "nat"
  WHEN "6" : samplenote% += 60 : PRINT "1/8 shrp"
  WHEN "7" : samplenote% += 70 : PRINT "1/4 shrp"
  WHEN "8" : samplenote% += 80 : PRINT "3/8 shrp"
  WHEN "9" : samplenote% += 90 : PRINT "shrp"
 ENDCASE
 COLOUR 0
 samplenote% += 5
 PROCconvertsamplenote
 sample%(count%) = samplenote%
 :
 NEXT
 :
 CLS
 PRINT'" OCTAVE SEQUENCES"
 PRINT'" How many different sections of"
 INPUT " octave sequences are there "octavesections%
 IF octavesections% > 1 THEN
  FOR count% = 2 TO octavesections%
   PRINT'" section ";count%;" begins at note number "
   INPUT x%
   octavesequences%(count%,0,0) = x%
  NEXT
 ENDIF
 :
 FOR count% = 1 TO octavesections%
  FOR pitch% = 0 TO 47
   entry$ = "n"
   IF pitch% MOD 4 = 0 AND grid$<>"s" THEN entry$ = "y"
   IF (pitch%-2)MOD4 = 0 THEN entry$ = "y"
   IF (pitch%-1)MOD2 = 0 AND grid$ = "e" THEN entry$ = "y"
   IF entry$ = "y" THEN
     PRINT '"In section ";count%;" the sequence of octaves for ";
    COLOUR 3 : PRINT pitchnames$(pitch%)
   COLOUR 0 : PRINT "has how many elements "
   INPUT e%
   PRINT""
   octavesequences%(count%,pitch%+1,0) = e%
   FOR counter% = 1 TO e%
    PRINT " element ";counter%;
    INPUT " is octave "o%
    octavesequences%(count%,pitch%+1,counter%) = o%
   NEXT
  ENDIF
 NEXT
 NEXT
 :
 CLS
 PRINT'" TRANSPOSITION LEVELS"
 PRINT'" How many different sections of"
 INPUT" transposition are there "transpositionsections%
 IF transpositionsections% > 1 THEN
 FOR count% = 2 TO transpositionsections%
  PRINT'" Section ";count%;
  INPUT " begins at note number "n%
  transpositionsequences%(count%,0) = n%
  PRINT" and transposes up/down by how many ";
  CASE grid$ OF
   WHEN "e" : PRINT "eighthtones" : INPUT " (+/- 1 etc) "x%
              transpositionsequences%(count%,1) = x%
   WHEN "q" : PRINT "quartertones" : INPUT " (+/- 1 etc) "x%
              transpositionsequences%(count%,1) = x% * 2
   WHEN "s" : PRINT "semitones" : INPUT " (+/- 1 etc) "x%
              transpositionsequences%(count%,1) = x% * 4
  ENDCASE
 NEXT
 ENDIF
 :
 CLS
 PRINT'" CONTOUR SEQUENCES"
 PRINT'" How many different sections of "
 INPUT " contour sequences are there "contoursections%
 IF contoursections%>1 THEN
  FOR count% = 2 TO contoursections%
   PRINT'" Section ";count%;
   INPUT " begins at note number "n%
   contoursequences%(count%,0) = n%
  NEXT
 ENDIF
 :
 FOR count% = 1 TO contoursections%
 PRINT'" In section ";count%;
 INPUT " there are how many contours "c%
 contoursequences%(count%,1) = c%
 PRINT""
 FOR counter% = 1 TO c%
 PRINT " number ";counter%;
 INPUT " is contour "contoor%
 contoursequences%(count%,counter%+1) = contoor%
 NEXT
 NEXT
 :
 contoursize% = 0 : seriesnote% = 1 : samplenote% = 0
 contoursequence% = 1 : transpositionsequence% = 1
 octavesequence% = 1 : transpositionsequences%(1,1) = 0
 contourloop% = 0 : octaveloop%() = 0
 :
 REPEAT
 seriesnote% += contoursize%
 IF seriesnote% >= contoursequences%(contoursequence%+1,0) AND contoursequences%(contoursequence%+1,0) <> 0 THEN
  contoursequence% += 1
  contourloop% = 0
 ENDIF
 :
 contourloop% += 1
 IF contourloop% > contoursequences%(contoursequence%,1) THEN contourloop% = 1
 contour% = contoursequences%(contoursequence%,contourloop%+1)
 contoursize% = contours%(contour%,0)
 :
 IF seriesnote% >= transpositionsequences%(transpositionsequence%+1,0) AND transpositionsequences%(transpositionsequence%+1,0) <> 0 THEN
  transpositionsequence% += 1
 ENDIF
 transposition% = transpositionsequences%(transpositionsequence%,1)
 :
 FOR count% = 1 TO contoursize%
  samplenote% += 1
  IF samplenote% > samplesize% THEN samplenote% = 1
  group%(count%) = sample%(samplenote%) + transposition%
 NEXT
 :
 IF seriesnote% >= octavesequences%(octavesequence%+1,0,0) AND octavesequences%(octavesequence%+1,0,0) <> 0 THEN
  octavesequence% += 1
  octaveloop%() = 0
 ENDIF
 :
 FOR count% = 1 TO contoursize%
  pitchclass% = group%(count%)
  REPEAT
   pitchclass% -= 48
  UNTIL pitchclass% < 51
  pitchclass% -= 2
  octaveloop%(pitchclass%) += 1
  IF octaveloop%(pitchclass%) > octavesequences%(octavesequence%,pitchclass%,0) THEN octaveloop%(pitchclass%) = 1
  oxtave% = octavesequences%(octavesequence%,pitchclass%,octaveloop%(pitchclass%))
  group%(count%) = (pitchclass%+2) + (48*oxtave%)
 NEXT
 :
 IF contoursize% > 1 THEN
  REPEAT
   FOR count% = 1 TO (contoursize%-1)
    IF group%(count%) >= group%(count%+1) THEN
     save% = group%(count%)
     group%(count%) = group%(count%+1)
     group%(count%+1) = save%
    ENDIF
   NEXT
   no% = 0
   FOR count% = 1 TO (contoursize%-1)
    IF group%(count%) > group%(count%+1) THEN no% = 1
   NEXT
  UNTIL no% = 0
 ENDIF
 :
 FOR count% = 1 TO contoursize%
  simplenote% = group%(contours%(contour%,count%))
  PROCconvertsimplenote
  pitches%((seriesnote%+count%)-1) = simplenote%
 NEXT
 :
 UNTIL ((seriesnote%+contoursize%)-1) >= numpitches%
 :
 FOR count% = 0 TO numpitches%-1 : pitches%(count%) = pitches%(count%+1) : NEXT
 PRINT'" Do you want to save this pitch string?"
 CASE GET$ OF
  WHEN "Y","y","+" : PROCsavepitchstring
  OTHERWISE
 ENDCASE
 :
 PROCinsertpitches
 :
 ENDPROC
 :
 REM*******************************************************
 :
 DEF PROCcopy
 :
 CLS : OFF
 repeatposit$ = "n"
 IF distort$ = "OFF" THEN dothis$ = "YES"
 IF distort$ = "ON" THEN
  IF distortpara$ = "attacks" THEN dothis$ = "YES" ELSE dothis$ = "NO"
 ENDIF
 IF dothis$ = "YES" THEN
 IF easiermenus$ = "n" THEN
 PRINT'" Copy one note - C            "
 PRINT " Copy passage  - c            "
 PRINT " Move one note - M            "
 PRINT " Move passage  - m            "
 PRINT " Extract       - E            "
 PRINT " Copy rhythm   - R            "
 PRINT " Save          - S            "
 PRINT " Import        - I            "
 ELSE
PRINT'" Copy one note - C            "
 PRINT '" Copy passage  - c            "
 PRINT '" Move one note - M            "
 PRINT '" Move passage  - m            "
 PRINT '" Extract       - E            "
 PRINT '" Copy rhythm   - R            "
 PRINT '" Save          - S            "
 PRINT '" Import        - I            "
 ENDIF
 CASE GET$ OF
  WHEN "c" : copymove$ = "C" : savevoice$ = "N" : justone$ = "n"
  WHEN "m" : copymove$ = "M" : savevoice$ = "N" : justone$ = "n"
  WHEN "C" : copymove$ = "C" : savevoice$ = "N" : justone$ = "y"
  WHEN "M" : copymove$ = "M" : savevoice$ = "N" : justone$ = "y"
  WHEN "E","e" :
   CLS : PRINT'" Copy-extract or move-extract? (C/M) "
   CASE GET$ OF
    WHEN "C","c" : copymove$ = "EC" : justone$ = "n"
    OTHERWISE copymove$ = "EM" : justone$ = "n"
   ENDCASE
   savevoice$ = "N"
  WHEN "R","r" : PROCcopyrhythm
  WHEN "S","s" : copymove$ = "C" : savevoice$ = "Y"
  WHEN "I","i" : copymove$ = "C" : savevoice$ = "N" : PROCimportvoice
  OTHERWISE
   copymove$ = "C" : savevoice$ = "N" : justone$ = "n"
 ENDCASE
 ELSE copymove$ = "C"
 ENDIF
 :
PROCcopy2
IF quickextract$ = "y" THEN quickextract$ = "n"
:
ENDPROC
:
*******************************************************************
:
DEF PROCcopy2
 :
 IF copymove$ = "M" OR copymove$ = "EM" THEN PROCundoprepare
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,69,67,54) ELSE PROCwindow(20,69,67,42)
 CLS
 :
 IF quickcopy$ = "n" THEN
  :
  IF screenvoices$ = "n" THEN
   INPUT'" Which voice? "voice%
   IF voice% = 0 THEN PROCpressenter
  ELSE
   PRINT'" Which screen voice "
    CASE GET$ OF
     WHEN "1" : voice% = 1
     WHEN "2" : voice% = 2
     WHEN "3" : voice% = 3
     OTHERWISE PROCpressenter
    ENDCASE
  ENDIF
  :
  IF copymove$ = "EC" OR copymove$ = "EM" THEN
   IF screenvoices$ = "y" THEN extractvoice% = displayvoices%(startv%+voice%-1) ELSE extractvoice% = voice%
  ENDIF : REM copymove$
  :
  IF screenvoices$ = "y" THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  samevoice% = voice%
  :
  CLS
  INPUT'" Starting at bar "copystartbar%
  IF copystartbar% = 0 THEN
  copystartbar% = holdbar1% : copystartbeat% = holdbeat1% : repeatposit$ = "y"
  ENDIF
  holdbar% = copystartbar%
  holdbar1% = copystartbar%
  IF repeatposit$ = "y" THEN
   PRINT'" bar ";copystartbar%;" beat ";copystartbeat%;"?"
   PRINT'" (for OK press 0, if not OK press X)"
    CASE GET$ OF
     WHEN"X","x" : PROCcopy
     OTHERWISE
    ENDCASE
  ELSE
   INPUT"             beat "beats%
   PROCalterbeats : copystartbeat% = beats%
   holdbeat% = copystartbeat%
   holdbeat1% = copystartbeat%
  ENDIF : REM repeatposit$
  :
  IF justone$ = "n" THEN
   PRINT'" Ending at bar "
   PRINT '" (for last bar press 0, for previous "
   INPUT  "  last bar press 0 twice) "copyendbar%
   IF copyendbar% > 0 THEN savethisbar% = copyendbar%
   IF copyendbar% > 0 THEN
    INPUT "           beat "beats%
    PROCalterbeats : copyendbeat% = beats% : savethisbeats% = beats%
    :
   ELSE
    thing$ = INKEY$(50)
    IF thing$ <> "" THEN
     copyendbar% = savethisbar% : copyendbeat% = savethisbeats%
     COLOUR 3
     PRINT'" bar ";copyendbar%;" beat ";copyendbeat%;"?"
     COLOUR 0
     PRINT '" (for OK press 0, if not OK press X)"
     CASE GET$ OF
      WHEN "X","x" : PROCcopy2
      OTHERWISE
     ENDCASE
    ENDIF : REM thing$
    :
   ENDIF : REM copyendbar%
    :
  ELSE
   copyendbar% = copystartbar%
   copyendbeat% = copystartbeat%
  ENDIF : REM justone$
  :
  IF copymove$ = "EC" OR copymove$ = "EM" THEN PROCextractinfo
  :
 ELSE : REM quickcopy$
  :
   IF screenvoices$ = "n" THEN
    :
    IF copysuccessively$ = "n" THEN
     INPUT ' ' " Which voice "voice%
     :
     IF voice% = 0 THEN
      :
      IF nodelay$ = "y" THEN voice% = displayvoices%(startv%) ELSE PROCpressenter
      :
     ENDIF : REM voice%
      :
    ELSE PROCcopysuccessively: REM copysuccessively
     :
    ENDIF : REM copysuccessively
     :
   ELSE : REM screenvoices$
    PRINT'" Which screen voice "
    CASE GET$ OF
     WHEN "1" : voice% = 1
     WHEN "2" : voice% = 2
     WHEN "3" : voice% = 3
     WHEN "x" : voice% = 1
     OTHERWISE PROCpressenter
    ENDCASE
   ENDIF : REM screenvoices$
   :
   IF copymove$ = "EC" OR copymove$ = "EM" THEN
    IF screenvoices$ = "y" THEN extractvoice% = displayvoices%(startv%+voice%-1) ELSE extractvoice% = voice%
   ENDIF : REM copymove$
     :
   IF screenvoices$ = "y" AND quickextract$ = "n" THEN voice% = displayvoices%(startv%+voice%-1)
   voice% -= 1 : samevoice% = voice%
   :
   PRINT ' " note number "
   CASE GET$ OF
    WHEN "1" : along% = 1
    WHEN "2" : along% = 2
    WHEN "3" : along% = 3
    WHEN "4" : along% = 4
    WHEN "5" : along% = 5
    WHEN "6" : along% = 6
    WHEN "7" : along% = 7
    WHEN "8" : along% = 8
    WHEN "9" : along% = 9
    WHEN "0" : along% = 0
   ENDCASE
   :
   IF along% = 0 THEN
    COLOUR 3 : PRINT ' along%+1 : COLOUR 0
    nothing$ = INKEY$(50)
   :
   ELSE
    another$ = INKEY$(waitafterfirst%)
    IF another$ <> "" THEN
     CASE another$ OF
      WHEN "1" : along% = (along%*10)+1
      WHEN "2" : along% = (along%*10)+2
      WHEN "3" : along% = (along%*10)+3
      WHEN "4" : along% = (along%*10)+4
      WHEN "5" : along% = (along%*10)+5
      WHEN "6" : along% = (along%*10)+6
      WHEN "7" : along% = (along%*10)+7
      WHEN "8" : along% = (along%*10)+8
      WHEN "9" : along% = (along%*10)+9
      WHEN "0" : along% = (along%*10)+0
     ENDCASE
    ENDIF : REM another$
    :
    another$ = INKEY$(waitaftersecond%)
    IF another$ <> "" THEN
     CASE another$ OF
      WHEN "1" : along% = (along%*10)+1
      WHEN "2" : along% = (along%*10)+2
      WHEN "3" : along% = (along%*10)+3
      WHEN "4" : along% = (along%*10)+4
      WHEN "5" : along% = (along%*10)+5
      WHEN "6" : along% = (along%*10)+6
      WHEN "7" : along% = (along%*10)+7
      WHEN "8" : along% = (along%*10)+8
      WHEN "9" : along% = (along%*10)+9
      WHEN "0" : along% = (along%*10)+0
     ENDCASE
    ENDIF : REM another$
    :
    COLOUR 3 : PRINT ' along% : COLOUR 0
    :
   ENDIF : REM along% <> 0
   :
   IF along% = 0 THEN along% = 1
    along%-=1
    copystartbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
    copystartbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
    holdbar% = copystartbar%
    holdbeat% = copystartbeat%
   IF justone$ = "n" THEN
    :
     PRINT'" to note number "
     :
     IF firstasking$ = "y" THEN
      IF copytoend$ = "y" THEN PRINT'" (for last type 0) "
     ELSE
      :
      IF copytoend$ = "y" THEN
       PRINT'" (for last type 0) "
      ELSE
       PRINT'" (for ";prevlast%;" type 0) "
      ENDIF : REM copytoend$
      :
     ENDIF : REM firstasking$
     :
     CASE GET$ OF
      WHEN "1" : along% = 1
      WHEN "2" : along% = 2
      WHEN "3" : along% = 3
      WHEN "4" : along% = 4
      WHEN "5" : along% = 5
      WHEN "6" : along% = 6
      WHEN "7" : along% = 7
      WHEN "8" : along% = 8
      WHEN "9" : along% = 9
      WHEN "0" :
       IF copytoend$ = "y" THEN
        along% = 0
       ELSE
        along% = prevlast% : usedprev$ = "y"
       ENDIF : REM copytoend$
      OTHERWISE
       IF copytoend$ = "y" THEN
        along% = 0
       ELSE
        IF firstasking$ = "y" THEN
         CLS : COLOUR 3
         PRINT'" COPYING TO END NOT ENABLED "
         COLOUR 0
         PRINT '" (press a key to continue)"
         prevlast% = 0
         CASE GET$ OF
         ENDCASE
        ELSE
         along% = prevlast% : usedprev$ = "y"
        ENDIF : REM firstasking$
       ENDIF : REM copytoend$
     ENDCASE
      firstasking$ = "n"
      :
     IF along% <> 0 AND usedprev$ = "n" THEN
      :
      another$ = INKEY$(waitafterfirst%)
      IF another$ <> "" THEN
       CASE another$ OF
        WHEN "1" : along% = (along%*10)+1
        WHEN "2" : along% = (along%*10)+2
        WHEN "3" : along% = (along%*10)+3
        WHEN "4" : along% = (along%*10)+4
        WHEN "5" : along% = (along%*10)+5
        WHEN "6" : along% = (along%*10)+6
        WHEN "7" : along% = (along%*10)+7
        WHEN "8" : along% = (along%*10)+8
        WHEN "9" : along% = (along%*10)+9
        WHEN "0" : along% = (along%*10)+0
       ENDCASE
      ENDIF : REM another$
      :
      another$ = INKEY$(waitaftersecond%)
      IF another$ <> "" THEN
       CASE another$ OF
        WHEN "1" : along% = (along%*10)+1
        WHEN "2" : along% = (along%*10)+2
        WHEN "3" : along% = (along%*10)+3
        WHEN "4" : along% = (along%*10)+4
        WHEN "5" : along% = (along%*10)+5
        WHEN "6" : along% = (along%*10)+6
        WHEN "7" : along% = (along%*10)+7
        WHEN "8" : along% = (along%*10)+8
        WHEN "9" : along% = (along%*10)+9
        WHEN "0" : along% = (along%*10)+0
       ENDCASE
      ENDIF : REM another$
      :
      prevlast% = along%
      COLOUR 3 : PRINT ' along% : COLOUR 0
      wait$ = INKEY$(50)
      :
     ENDIF : REM along% <> 0
     :
     usedprev$ = "n"
     :
     IF along% = 0 THEN
      copyendbar% = 0
     ELSE
      along%-=1
      copyendbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
      copyendbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
     ENDIF : REM along$
   ELSE
     copyendbar% = copystartbar%
     copyendbeat% = copystartbeat%
   ENDIF : REM justone$ = "n"
   :
   IF copymove$ = "EC" OR copymove$ = "EM" THEN PROCextractinfo
   :
 ENDIF : REM quickcopy$ = "n"
 :
 :
 value% = (copystartbar%*10^3)+copystartbeat%
 IF value% <= array%(0,0,voice%)DIV10^3 THEN
  startatcell% = 0
 ELSE
  PROCsearch(value%)
  startatcell% = startcell%
 ENDIF : REM value%
 :
 IF copyendbar% = 0 THEN
  endatcell% = numusedcells%(voice%) - 1
 ELSE
  value% = (copyendbar%*10^3)+copyendbeat%
  IF value% >= array%(numusedcells%(voice%)-1,0,voice%)DIV10^3 THEN
   endatcell% = numusedcells%(voice%) - 1
  ELSE
   PROCsearch(value%)
   IF shunt$ = "N" THEN endatcell% = startcell% ELSE endatcell% = startcell% - 1
  ENDIF : REM value%
  :
 ENDIF : REM copyendbar%
 :
 manyattacks% = endatcell% - startatcell% + 1
 REM create 'gap' between beat-of-bar and first actual attack
 carrybars% = (array%(startatcell%,0,voice%)DIV10^6)-copystartbar%
 carrybeats% = ((array%(startatcell%,0,voice%)DIV10^3)MOD10^3)-copystartbeat%
 attacks1%(0) = (carrybars%*960)+carrybeats%
 :
 IF copymove$ = "C" OR copymove$ = "M" THEN
  FOR count% = 0 TO (manyattacks%-1)
   IF count% > 0 THEN
    carrybars% = (array%(startatcell%+count%,0,voice%)DIV10^6)-(array%(startatcell%+count%-1,0,voice%)DIV10^6)
    carrybeats% = ((array%(startatcell%+count%,0,voice%)DIV10^3)MOD10^3)-((array%(startatcell%+count%-1,0,voice%)DIV10^3)MOD10^3)
    attacks1%(count%) = attacks1%(count%-1) + ((carrybars%*960)+carrybeats%)
   ENDIF : REM count% > 0
  :
   pitches%(count%) = array%(startatcell%+count%,0,voice%)MOD10^3
   dur% = (array%(startatcell%+count%,1,voice%)DIV10)MOD10^3
   brrr% = array%(startatcell%+count%,0,voice%)DIV10^6 : PROCreconvertdur
   durations%(count%) = dur%
   amplitudes%(count%) = (array%(startatcell%+count%,1,voice%))MOD10
   envelopes%(count%) = (array%(startatcell%+count%,2,voice%))DIV10^2
   glissandos%(count%) = array%(startatcell%+count%,1,voice%)DIV10^4
   inflections%(count%) = array%(startatcell%+count%,2,voice%)MOD10^2
  NEXT
 ELSE
  :
  PROCextract
  :
 ENDIF : REM copymove$
 :
 IF copymove$ = "M" THEN
  numnotes% = manyattacks% : startcell% = startatcell%
  FOR count% = startcell% TO (startcell%+(numnotes%-1))
   FOR counter% = 0 TO 1
    barno% = (array%(count%,0,voice%)DIV10^6)-counter%
    beatnum% = ((array%(count%,0,voice%)DIV10^3)MOD10^3)
    :
    group1start% = (disarray%(barno%,0,voice%)DIV10^7)*beatfactor%
    group1end% = group1start% + (((disarray%(barno%,0,voice%)DIV10^5)MOD10^2)*beatfactor%)-1
    IF beatnum%+(960*counter%) >= group1start% AND beatnum%+(960*counter%) <= group1end% THEN
     disarray%(barno%,0,voice%) = disarray%(barno%,0,voice%)MOD10^3
    ENDIF : REM beatnum%
    :
    group2start% = ((disarray%(barno%,0,voice%)DIV10)MOD10^2)*beatfactor%
    group2end% = group2start%+((((disarray%(barno%,0,voice%)MOD10)*10)+(disarray%(barno%,1,voice%)DIV10^8))*beatfactor%)-1
    IF beatnum%+(960*counter%) >= group2start% AND beatnum%+(960*counter%) <= group2end% THEN
     disarray%(barno%,0,voice%) = (disarray%(barno%,0,voice%)DIV10^3)*10^3
     disarray%(barno%,1,voice%) = disarray%(barno%,1,voice%)MOD10^6
    ENDIF : REM beatnum%
    group3start%=((disarray%(barno%,1,voice%)DIV10^4)MOD10^2)*beatfactor%
    group3end% = group3start% + (((disarray%(barno%,1,voice%)MOD10^4)DIV10^2)*beatfactor%)-1
    IF beatnum%+(960*counter%) >= group3start% AND beatnum%+(960*counter%) <= group3end% THEN
     disarray%(barno%,1,voice%) = (disarray%(barno%,1,voice%)DIV10^6)*10^6
    ENDIF : REM beatnum%
    group4start% = (disarray%(barno%,2,voice%)DIV10^7)*beatfactor%
    group4end% = group4start%+(((disarray%(barno%,2,voice%)DIV10^5)MOD10^2)*beatfactor%)-1
    IF beatnum%+(960*counter%) >= group4start% AND beatnum%+(960*counter%) <= group4end% THEN
     disarray%(barno%,2,voice%) =  disarray%(barno%,2,voice%)MOD10^3
    ENDIF : REM beatnum%
    group5start% = ((disarray%(barno%,2,voice%)MOD10^3)DIV10)*beatfactor%
    group5end% = group5start%+((((disarray%(barno%,2,voice%)MOD10)*10)+(disarray%(barno%,3,voice%)DIV10^8))*beatfactor%)-1
    IF beatnum%+(960*counter%) >= group5start% AND beatnum%+(960*counter%) <= group5end% THEN
     disarray%(barno%,2,voice%) = (disarray%(barno%,2,voice%)DIV10^3)*10^3
     disarray%(barno%,3,voice%) = disarray%(barno%,3,voice%)MOD10^6
    ENDIF : REM beatnum%
    group6start% = ((disarray%(barno%,3,voice%)DIV10^4)MOD10^2)*beatfactor%
    group6end% = group6start% + (((disarray%(barno%,3,voice%)DIV10^2)MOD10^2)*beatfactor%)-1
    IF beatnum%+(960*counter%) >= group6start% AND beatnum%+(960*counter%) <= group6end% THEN
     disarray%(barno%,3,voice%)=(disarray%(barno%,3,voice%)DIV10^6)*10^6
    ENDIF : REM beatnum%
    :
   NEXT
   :
  NEXT : REM count%
  :
  PROCshuntleft(startcell%,numnotes%)
 ENDIF : REM copymove$
 :
 IF distort$ = "OFF" THEN
 numpitches% = manyattacks% : numdurations% = manyattacks% : numamplitudes% = manyattacks%
  numenvelopes% = manyattacks% : numinflections% = manyattacks% : method$ = "raw" : copyit$ = "ON"
  IF seeequalize$ = "y" THEN seeequalizey$ = "y"
  IF seereorder$ = "y" THEN seereordery$ = "y"
  PROCinsertattacks
 ELSE
  PROCdistort
 ENDIF : REM distort$
 :
 $ = "n" : quickextract$ = "n" : usedprev$ = "n"
 ENDPROC
 :
 REM**************************************************************
 :
 DEF PROCdistort
 :
 CLS
 CASE distortpara$ OF
  WHEN "attacks" :
  :
  INPUT'" How many bands? (0 = previous values) "answer%
  IF answer% <> 0 THEN numbands% = answer%
   :
 IF answer% > 0 THEN
  IF answer% = 1 THEN
    CLS
    PRINT'" intervals to be multiplied by"
    PRINT'" random percentages between..."
    PRINT '" (for ";distortparas%(1,2);
    INPUT" press 0) "number%
    IF number% = 0 THEN distortparas%(1,2) = distortparas%(1,2) ELSE distortparas%(1,2) = number%
    PRINT'" and...(for ";distortparas%(1,3);
    INPUT " press 0) "number%
    IF number% = 0 THEN distortparas%(1,3) = distortparas%(1,3) ELSE distortparas%(1,3) = number%
    distortparas%(1,0) = 0 : distortparas%(1,1) = 960000
    :
   ELSE
    :
    FOR count% = 1 TO numbands%
    CLS
     PRINT'" Band ";count%;"'s intervals are between (incl.) "
     INPUT'"                 bars..."bars%
     INPUT'"                 beats..."beats%
     PROCalterbeats
      distortparas%(count%,0) = (bars%*960) + beats%
      INPUT' "            and bars..."bars%
      INPUT' "                beats..."beats%
      PROCalterbeats
distortparas%(count%,1) = (bars%*960) + beats%
      PRINT'" which are to be multiplied by random "
      INPUT'" percentages between..."distortparas%(count%,2)
      INPUT'"                 and..."distortparas%(count%,3)
     NEXT
     :
    ENDIF
ELSE
COLOUR 3
PRINT'" values as last time?"
PRINT'distortparas%(1,0);" - ";distortparas%(1,1);"  ";distortparas%(1,2);"% - ";distortparas%(1,3)"%"
IF numbands% > 1 THEN PRINT distortparas%(2,0);" - ";distortparas%(2,1);"  ";distortparas%(2,2);"% - ";distortparas%(2,3)"%"
COLOUR 0
CASE GET$ OF
 WHEN"y","Y":
 OTHERWISE
ENDCASE
ENDIF
    :
   nextinterval% = attacks1%(1) - attacks1%(0)
   FOR count% = 1 TO manyattacks% - 1
    :
    interval% = nextinterval%
    :
    band% = 0
    FOR counter% = 1 TO numbands%
     IF interval% >= distortparas%(counter%,0) AND interval% <= distortparas%(counter%,1) THEN band% = counter%
    NEXT
    :
    IF band% > 0 THEN percentage1% = distortparas%(band%,2) ELSE percentage1% = 100
    IF band% > 0 THEN percentage2% = distortparas%(band%,3) ELSE percentage2% = 100
    range% = percentage2%-percentage1%
    IF range% = 0 THEN
     percentage3 = percentage1%
    ELSE
     percentage3 = RND(range%) + percentage1% - 1
     percentage3 += (RND(99))/100
    ENDIF
    :
    nextinterval% = attacks1%(count%+1) - attacks1%(count%)
    attacks1%(count%) = attacks1%(count%-1) + ((interval%*percentage3)DIV100)
    :
   NEXT
   :
   method$ = "raw" : copyit$ = "ON" : distort$ = "OFF"
  PROCinsertattacks
  :
  WHEN "pitches" :
  :
 PROCwindow(20,69,70,54)
   PRINT'" Is the grid semi-, quarter- or eighthtone (S/Q/E)"
   PRINT'" (0 = previous) "
    CASE GET$ OF
     WHEN "S","s" : distortgrid$ = "S"
     WHEN "Q","q" : distortgrid$ = "Q"
     WHEN "E","e" : distortgrid$ = "E"
     OTHERWISE distortgrid$ = distortgrid$
    ENDCASE
    :
    INPUT'" How many bands? "numbands%
    IF numbands% = 0 THEN numbands% = 1
    :
    IF numbands% = 1 THEN
     distortparas%(1,0) = 0
     distortparas%(1,1) = 1000
     PRINT'" Pitches are to be raised/lowered randomly by"
     PRINT " between how many ";
     CASE distortgrid$ OF
      WHEN "S" : PRINT"semitones (-1,1 etc) "
      INPUT" (11 = previous) "distortparas%(1,2)
      IF distortparas%(1,2) = 11 THEN
       distortparas%(1,2) = previousdistort1%
       COLOUR 3
       PRINT' previousdistort1%
       COLOUR 0
      ENDIF
      WHEN "Q" : PRINT"quartertones (-1,1 etc) "
      INPUT" (0 = previous) "distortparas%(1,2)
      IF distortparas%(1,2) = 0 THEN
       distortparas%(1,2) = previousdistort1%
       COLOUR 3
       PRINT' previousdistort1%
       COLOUR 0
      ENDIF
     WHEN "E" : INPUT"eighthtones (-1,1 etc) "distortparas%(1,2)
     ENDCASE
     PRINT '" and how many ";
     CASE distortgrid$ OF
      WHEN "S" : INPUT"semitones "distortparas%(1,3)
      IF distortparas%(1,3) = 11 THEN
       distortparas%(1,3) = previousdistort2%
       COLOUR 3
       PRINT ' previousdistort2%
       COLOUR 0
       pause$ = INKEY$(50)
      ENDIF
      WHEN "Q" : INPUT"quartertones "distortparas%(1,3)
      IF distortparas%(1,3) = 0 THEN
       distortparas%(1,3) = previousdistort2%
       COLOUR 3
       PRINT' previousdistort2%
       COLOUR 0
       pause$ = INKEY$(50)
      ENDIF
     WHEN "E" : INPUT"eighthtones "distortparas%(1,3)
     ENDCASE
      previousdistort1% = distortparas%(1,2)
      previousdistort2% = distortparas%(1,3)
     :
    ELSE
     :
     FOR count% = 1 TO numbands%
      PRINT'" Band ";count%;" is from the ";
      FOR counter% = 0 TO 1
       IF counter% = 0 THEN PRINT"lower note" ELSE PRINT'"to the upper note"
       PRINT'"             pitchclass ";
       COLOUR 3
       CASE GET$ OF
        WHEN "C","c" : note% = 4 : PRINT "C"
        WHEN "D","d" : note% = 12 : PRINT "D"
        WHEN "E","e" : note% = 20 : PRINT "E"
        WHEN "F","f" : note% = 24 : PRINT "F"
        WHEN "G","g" : note% = 32 : PRINT "G"
        WHEN "A","a" : note% = 40 : PRINT "A"
        WHEN "B","b" : note% = 48 : PRINT "B"
        OTHERWISE VDU 7 : PROCdistort
       ENDCASE
       COLOUR 0
       PRINT"             accidental ";
       COLOUR 3
       CASE GET$ OF
        WHEN "1" : note% -= 4 : PRINT "flat"
        WHEN "2" : note% -= 3 : PRINT "3/8 flat"
        WHEN "3" : note% -= 2 : PRINT "1/4 flat"
        WHEN "4" : note% -= 1 : PRINT "1/8 flat"
        WHEN "5" : note% -= 0 : PRINT "nat"
        WHEN "6" : note% += 1 : PRINT "1/8 shrp"
        WHEN "7" : note% += 2 : PRINT "1/4 shrp"
        WHEN "8" : note% += 3 : PRINT "3/8 shrp"
        WHEN "9" : note% += 4 : PRINT "shrp"
       ENDCASE
       COLOUR 0
       PRINT"             octave ";
       COLOUR 3
       oct% = VAL(GET$) : oct%=oct%DIV1 : note% += (48*oct%) : PRINT oct%
       COLOUR 0
       distortparas%(count%,counter%) = note%
      NEXT
      :
      PRINT'" and pitches are to be raised/lowered"
      PRINT " randomly by between how many ";
      CASE distortgrid$ OF
       WHEN "S" : INPUT"semitones "distortparas%(count%,2)
       WHEN "Q" : INPUT"quartertones "distortparas%(count%,2)
       WHEN "E" : INPUT"eighthtones "distortparas%(count%,2)
      ENDCASE
      PRINT" and how many ";
      CASE distortgrid$ OF
       WHEN "S" : INPUT"semitones "distortparas%(count%,3)
       WHEN "Q" : INPUT"quartertones "distortparas%(count%,3)
       WHEN "E" : INPUT"eighthtones "distortparas%(count%,3)
      ENDCASE
      :
     NEXT
     :
    ENDIF
     :
    nextpitch% = pitches%(0)
    FOR count% = 0 TO (manyattacks%-1)
    :
     note% = nextpitch%DIV100
     accid% = (nextpitch%DIV10)MOD10
     oct% = nextpitch%MOD10
     CASE note% OF
      WHEN 0 : pitch% = 4
      WHEN 1 : pitch% = 12
      WHEN 2 : pitch% = 20
      WHEN 3 : pitch% = 24
      WHEN 4 : pitch% = 32
      WHEN 5 : pitch% = 40
      WHEN 6 : pitch% = 48
     ENDCASE
     accid% -= 5 : pitch% += accid%
     pitch% += (48*oct%)
     :
     FOR counter% = 1 TO numbands%
      IF pitch%>=distortparas%(counter%,0)ANDpitch%<=distortparas%(counter%,1) THEN band% = counter%
     NEXT
     :
     lower% = distortparas%(band%,2)
     upper% = distortparas%(band%,3)
     x% = 0 - lower%
     range% = upper% + x% + 1
     IF range% = 1 THEN inc% = 1-(x%+1) ELSE inc% = RND(range%)-(x%+1)
     IF distortgrid$ = "S" THEN inc% = inc%*4
     IF distortgrid$ = "Q" THEN inc% = inc%*2
     pitch% += inc%
     :
     FOR counter% = 0 TO 9
      IF pitch% > 2 + (48*counter%) THEN
       octave% = counter%
      ENDIF
     NEXT
     :
     pitch% -= (48*octave%)
      IF pitch% > 2 AND pitch% < 8 THEN
        pitchclass% = 0 : diff% = pitch% - 4
       ENDIF
      IF pitch% > 7 AND pitch% < 16 THEN
        pitchclass% = 1 : diff% = pitch% - 12
       ENDIF
      IF pitch% > 15 AND pitch% < 23 THEN
        pitchclass% = 2 : diff% = pitch% - 20
       ENDIF
      IF pitch% > 22 AND pitch% < 29 THEN
        pitchclass% = 3 : diff% = pitch% - 24
       ENDIF
      IF pitch% > 28 AND pitch% < 36 THEN
        pitchclass% = 4 : diff% = pitch% - 32
       ENDIF
      IF pitch% > 35 AND pitch% < 44 THEN
        pitchclass% = 5 : diff% = pitch% - 40
       ENDIF
      IF pitch% > 43 AND pitch% < 51 THEN
        pitchclass% = 6 : diff% = pitch% - 48
       ENDIF
      accid% = diff% + 5 : nextpitch% = pitches%(count%+1)
      pitches%(count%) = (pitchclass%*100)+(accid%*10)+octave%
      :
     NEXT
      :
      numpitches% = manyattacks%
    distort$ = "OFF" : PROCinsertpitches
     :
WHEN "durations" :
:
PROCwindow(20,69,70,54)
   PRINT'" distort durations between"
   INPUT" what percentage "firstpercent%
   IF firstpercent% = 0 THEN
    PRINT '" that's ";prevfirstpercent%;" then?"
    CASE GET$ OF
     WHEN "Y","y" :
     firstpercent% = prevfirstpercent%
     OTHERWISE  firstpercent% = prevfirstpercent%
     ENDCASE
    ENDIF
   INPUT" and what percentage "secondpercent%
    IF secondpercent% = 0 THEN
    PRINT '" that's ";prevsecondpercent%;" then?"
    CASE GET$ OF
     WHEN "Y","y","0" :
     secondpercent% = prevsecondpercent%
     OTHERWISE secondpercent% = prevsecondpercent%
     ENDCASE
    ENDIF
 :
prevfirstpercent% = firstpercent% : prevsecondpercent% = secondpercent%
:
FOR count% = manyattacks% TO 1 STEP -1
  durations%(count%) = durations%(count%-1)
NEXT
:
FOR count% = 1 TO manyattacks%
multiplier = (RND(secondpercent%-firstpercent%)+firstpercent%)/100
  durations%(count%) = durations%(count%)*multiplier
NEXT
:
FOR count% = 0 TO (manyattacks%-1)
 durations%(count%) = durations%(count%+1)
NEXT
 durations%(manyattacks%) = 0
:
 numdurations% = manyattacks%
    distort$ = "OFF" : PROCinsertdurations



WHEN "amplitudes" :
:
PROCwindow(20,69,70,54)
CLS
PRINT'" Increase or decrease by 1 notch (I/D) "
 CASE GET$ OF
  WHEN "I","i" :
 FOR count% = 0 TO manyattacks%-1
 IF amplitudes%(count%) < 9 THEN amplitudes%(count%) += 1
 IF envelopes%(count%) <> 9 THEN
 number% = envelopes%(count%) DIV 10^3
 IF number% = 0 THEN numphases% = 1
 IF number% > 0 AND number% < 100 THEN numphases% = 2
 IF number% > 99 THEN numphases% = 3
  CASE numphases% OF
   WHEN 1 :
    IF envelopes%(count%)MOD10 < 9 THEN envelopes%(count%) += 1
   WHEN 2 :
    IF envelopes%(count%)MOD10 < 9 THEN envelopes%(count%) += 1
    IF (envelopes%(count%)DIV10)MOD10 < 9 THEN envelopes%(count%) += 10
   WHEN 3 :
    IF envelopes%(count%)MOD10 < 9 THEN envelopes%(count%) += 1
    IF (envelopes%(count%)DIV10)MOD10 < 9 THEN envelopes%(count%) += 10
    IF (envelopes%(count%)DIV100)MOD10 < 9 THEN envelopes%(count%) += 100
  ENDCASE
 ENDIF
 NEXT
:
 OTHERWISE
 FOR count% = 0 TO manyattacks%-1
 IF amplitudes%(count%) > 0 THEN amplitudes%(count%) -= 1
 IF envelopes%(count%) <> 9 THEN
 number% = envelopes%(count%) DIV 10^3
 IF number% = 0 THEN numphases% = 1
 IF number% > 0 AND number% < 100 THEN numphases% = 2
 IF number% > 99 THEN numphases% = 3
 :
  CASE numphases% OF
   WHEN 1 :
    IF envelopes%(count%)MOD10 > 0 THEN envelopes%(count%) -= 1
   WHEN 2 :
    IF envelopes%(count%)MOD10 > 0 THEN envelopes%(count%) -= 1
    IF (envelopes%(count%)DIV10)MOD10 > 0 THEN envelopes%(count%) -= 10
   WHEN 3 :
    IF envelopes%(count%)MOD10 > 0 THEN envelopes%(count%) -= 1
    IF (envelopes%(count%)DIV10)MOD10 > 0 THEN envelopes%(count%) -= 10
    IF (envelopes%(count%)DIV100)MOD10 > 0 THEN envelopes%(count%) -= 100
  ENDCASE
 ENDIF
 NEXT
:
ENDCASE
 :
 numenvelopes% = manyattacks%
 distort$ = "OFF" : PROCinsertenvelopes
:
WHEN "envelopes" :
   PRINT'" give 1st envelope point random "
   INPUT" percentages between what percentage "firstpercent%
   INPUT" and what percentage "secondpercent%
 :
FOR count% = manyattacks% TO 1 STEP -1
  envelopes%(count%) = envelopes%(count%-1)
  glissandos%(count%) = glissandos%(count%-1)
NEXT
:
FOR count% = 1 TO manyattacks%

newpercentage% = RND(secondpercent%-(firstpercent%-1))+(firstpercent%)
ph2% = envelopes%(count%) DIV 10^5
amps% = envelopes%(count%) MOD 10^3
ph1% = newpercentage%
  envelopes%(count%) = (ph2%*10^5)+(ph1%*10^3)+amps%
  glissandos%(count%) = glissandos%(count%)
:
NEXT
:
IF numphases% = 3 THEN
:
  PRINT'" give 2nd envelope point random "
   INPUT" percentages between what percentage "firstpercent%
   INPUT" and what percentage "secondpercent%
:
FOR count% = 1 TO manyattacks%

newpercentage% = RND(secondpercent%-(firstpercent%-1))+(firstpercent%)
ph1% = (envelopes%(count%) DIV 10^3) MOD 10^2
amps% = envelopes%(count%) MOD 10^3
ph2% = newpercentage%
  envelopes%(count%) = (ph2%*10^5)+(ph1%*10^3)+amps%
  glissandos%(count%) = glissandos%(count%)
:
NEXT
:
ENDIF
:
FOR count% = 0 TO (manyattacks%-1)
 envelopes%(count%) = envelopes%(count%+1)
NEXT
envelopes%(manyattacks%) = 0
 numenvelopes% = manyattacks%
 distort$ = "OFF" : PROCinsertenvelopes
:
WHEN "inflections" :
:
PROCwindow(20,69,70,55)
   PRINT'" distort inflections up or down "
   PRINT" by up to how many cents  "
   INPUT" (max. 49) "cents%
 :
FOR count% = manyattacks% TO 1 STEP -1
  inflections%(count%) = inflections%(count%-1)
NEXT
:
FOR count% = 1 TO manyattacks%
:
REPEAT
factor% = RND(cents%)
upordown% = RND(2)
:
IF upordown% = 1 THEN
:
 inflections%(count%) = inflections%(count%)+factor%
ELSE
 inflections%(count%) = inflections%(count%)-factor%                                             :
ENDIF
:
UNTIL inflections%(count%) > 0 AND inflections%(count%) < 100
:
NEXT
:
FOR count% = 0 TO (manyattacks%-1)
 inflections%(count%) = inflections%(count%+1)
NEXT
inflections%(manyattacks%) = 0
:
 numinflections% = manyattacks%
    distort$ = "OFF" : PROCinsertinflections
:
 ENDCASE
 :
 ENDPROC
 :
 REM****************************************************
 :
 DEF PROCreorderattacks
 :
 r1% = 0
 :
 REM fills attacks3% with original actual durats in beats
 attacks2%() = attacks1%()
 FOR count% = 0 TO manyattacks%-2
  attacks3%(count%) = attacks2%(count%+1)-attacks2%(count%)
 NEXT
 :
 PRINT''" Random or determined order? (R/1 or D)"
 CASE GET$ OF
  WHEN "D","d" :
 CLS
 PRINT''" There are ";manyattacks%-1;" durations in the group"
 FOR count% = 1 TO manyattacks%-1
  PRINT'" New duration ";count%;
  INPUT" is now to be old duration "r%
  attacks1%(count%) = attacks1%(count%-1)+attacks3%(r%-1)
 NEXT
 OTHERWISE
  CLS
  PRINT''" There are ";manyattacks%-1;" durations in the group"
  PRINT'" How many durations do you want to re-order? "
  INPUT " (for all press 0) "howmany%
  IF howmany% = 0 THEN howmany% = manyattacks%-1
  INPUT'" Starting at duration number "number%
  IF number% = 0 THEN number% = 1
  INPUT'" Chance of repeating original order(%) "chanceofnext%
  attacks2%() = 0 : count% = number%
  REPEAT
   PROCchoosenext
 IF choosenext$ = "y" AND r1% < howmany% THEN
    r1% = r1% + 1
   ELSE
    r1% = RND(howmany%)
   ENDIF
   r% = r1%+number%-1
  IF attacks2%(r%) = 0 THEN
    attacks1%(count%) = attacks1%(count%-1)+attacks3%(r%-1)
    attacks2%(r%) = 1 : count% += 1
   ENDIF
  UNTIL count% = howmany%+number%
 ENDCASE
 :
 reordered$ = "y" : seereordery$ = "n"
 PROCinsertattacks
 :
 ENDPROC
 :
 REM********************************************************
 :
 DEF PROCchoosenext
 :
 numb% = RND(100)
 IF numb% >= chanceofnext% THEN choosenext$ = "n" ELSE choosenext$ = "y"
 ENDPROC
 :
 REM********************************************************
 :
DEF PROCsavepitchstring
 :
*Dir SDFS::RISCOSpi.$.CAC.Files
 firstnaming$ = "n"
 CLS
 IF filenamestg$ = "" THEN
 INPUT'" filename "filenamestg$
 firstnaming$ = "y"
 ENDIF
 IF firstnaming$ = "n" THEN
 PRINT'" as '";filenamestg$;"'?"
 CASE GET$ OF
  WHEN "Y","y","+" :
  OTHERWISE INPUT'" filename "filenamestg$
 ENDCASE
 ENDIF
 :
 channel = OPENOUT filenamestg$
 PRINT#channel, numpitches%
 PRINT#channel, grid$
 PRINT#channel, samplesize%
 PRINT#channel, octavesections%
 PRINT#channel, transpositionsections%
 PRINT#channel, contoursections%
 FOR a% = 0 TO samplesize%
  PRINT#channel, sample%(a%)
 NEXT
 FOR a% = 0 TO octavesections%
  FOR b% = 0 TO 48
    FOR c% = 0 TO 11
      PRINT#channel, octavesequences%(a%,b%,c%)
    NEXT
   NEXT
  NEXT
 FOR a% = 0 TO transpositionsections%
  FOR b% = 0 TO 1
      PRINT#channel, transpositionsequences%(a%,b%)
   NEXT
  NEXT
 FOR a% = 0 TO contoursections%
  FOR b% = 0 TO 11
      PRINT#channel, contoursequences%(a%,b%)
   NEXT
  NEXT
 :
 CLOSE#channel
 *NoDir
 :
 ENDPROC
 :
 REM***************************************************
 :
 DEF PROCloadpitchstring
 :
*Dir SDFS::RISCOSpi.$.CAC.Files
 INPUT'" filename "filenamestg$
 channel = OPENIN filenamestg$
 REPEAT
  INPUT#channel, numpitches%
  INPUT#channel, grid$
  INPUT#channel, samplesize%
  INPUT#channel, octavesections%
  INPUT#channel, transpositionsections%
  INPUT#channel, contoursections%
  FOR a% = 0 TO samplesize%
   INPUT#channel, sample%(a%)
  NEXT
  FOR a% = 0 TO octavesections%
   FOR b% = 0 TO 48
     FOR c% = 0 TO 11
      INPUT#channel, octavesequences%(a%,b%,c%)
      NEXT
      NEXT
      NEXT
  FOR a% = 0 TO transpositionsections%
   FOR b% = 0 TO 1
      INPUT#channel, transpositionsequences%(a%,b%)
      NEXT
      NEXT
  FOR a% = 0 TO contoursections%
   FOR b% = 0 TO 11
      INPUT#channel, contoursequences%(a%,b%)
      NEXT
      NEXT
 UNTIL EOF#channel
 CLOSE#channel
 *NoDir
 :
 ENDPROC
 :
 REM*****************************************************
 :
 DEF PROCeditpitchstring
 :
 IF loadstring$ = "y" THEN PROCloadpitchstring
 :
 PRINT'" Change number of notes in the"
 PRINT " pitch string? (Y/+ OR N/return)"
 PRINT'" (currently ";numpitches%;")"
 CASE GET$ OF
  WHEN "Y","y","+","=" : do$ = "y"
 OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 PRINT'" Total number of notes in the"
 INPUT " pitch string (inc. sample) "numpitches%
 ENDIF
 CLS
 :
 PRINT'" Change the sample?"
 PRINT'" currently "
 FOR count% = 1 TO samplesize%
  x% = sample%(count%)
  WHILE x% > 52
   x% -= 48
  ENDWHILE
  CASE x% OF
   WHEN 5 : PRINT count%;". C nat"
   WHEN 9 : PRINT count%;". C shrp"
   WHEN 13 : PRINT count%;". D nat"
   WHEN 17 : PRINT count%;". E flat"
   WHEN 21 : PRINT count%;". E nat"
   WHEN 25 : PRINT count%;". F nat"
   WHEN 29 : PRINT count%;". F shrp"
   WHEN 33 : PRINT count%;". G nat"
   WHEN 37 : PRINT count%;". A flat"
   WHEN 41 : PRINT count%;". A nat"
   WHEN 45 : PRINT count%;". B flat"
   WHEN 49 : PRINT count%;". B nat"
   OTHERWISE
  ENDCASE
 NEXT
 REM eighthtones not yet implemented!
 CASE GET$ OF
  WHEN "Y","y","+","=" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 PRINT'" Change the number of notes in the sample?"
 PRINT'" Currently ";samplesize%
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 INPUT'" How many notes in the sample? "samplesize%
 ENDIF
 PRINT'" Change any of the sample's notes?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 INPUT'" How many "x%
 FOR count% = 1 TO x%
IF x% < samplesize% THEN
 PRINT'" note ";count%;" is note number "
 INPUT y%
  PRINT'" this note is now pitchclass ";
ELSE
 y% = count%
 PRINT'" note ";count%;" is now pitchclass ";
ENDIF
 COLOUR 3
 CASE GET$ OF
  WHEN "C","c" : samplenote% = 0 : PRINT "C"
  WHEN "D","d" : samplenote% = 1 : PRINT "D"
  WHEN "E","e" : samplenote% = 2 : PRINT "E"
  WHEN "F","f" : samplenote% = 3 : PRINT "F"
  WHEN "G","g" : samplenote% = 4 : PRINT "G"
  WHEN "A","a" : samplenote% = 5 : PRINT "A"
  WHEN "B","b" : samplenote% = 6 : PRINT "B"
 ENDCASE
 samplenote% = samplenote%*100
 COLOUR 0
 PRINT "           accidental ";
 COLOUR 3
 CASE GET$ OF
  WHEN "1" : samplenote% += 10 : PRINT "flat"
  WHEN "2" : samplenote% += 20 : PRINT "3/8 flat"
  WHEN "3" : samplenote% += 30 : PRINT "1/4 flat"
  WHEN "4" : samplenote% += 40 : PRINT "1/8 flat"
  WHEN "5" : samplenote% += 50 : PRINT "nat"
  WHEN "6" : samplenote% += 60 : PRINT "1/8 shrp"
  WHEN "7" : samplenote% += 70 : PRINT "1/4 shrp"
  WHEN "8" : samplenote% += 80 : PRINT "3/8 shrp"
  WHEN "9" : samplenote% += 90 : PRINT "shrp"
 ENDCASE
 COLOUR 0
 samplenote% += 5
 PROCconvertsamplenote
 sample%(y%) = samplenote%
 :
 NEXT
 ENDIF
 :
 ENDIF
 :
 CLS
 PRINT'" Make changes to the octave sequences?"
 PRINT'" Currently"
 VDU 14
  FOR a% = 1 TO octavesections%
   FOR b% = 3 TO 47 STEP 4
    FOR c% = 1 TO 11
     IF b% = 3 AND c% = 1 THEN PRINT'" C nat"
     IF b% = 7 AND c% = 1 THEN PRINT'" C shrp"
     IF b% = 11 AND c% = 1 THEN PRINT'" D nat"
     IF b% = 15 AND c% = 1 THEN PRINT'" E flat"
     IF b% = 19 AND c% = 1 THEN PRINT'" E nat"
     IF b% = 23 AND c% = 1 THEN PRINT'" F nat"
     IF b% = 27 AND c% = 1 THEN PRINT'" F shrp"
     IF b% = 31 AND c% = 1 THEN PRINT'" G nat"
     IF b% = 35 AND c% = 1 THEN PRINT'" A flat"
     IF b% = 39 AND c% = 1 THEN PRINT'" A nat"
     IF b% = 43 AND c% = 1 THEN PRINT'" B flat"
     IF b% = 47 AND c% = 1 THEN PRINT'" B nat"
IF octavesequences%(a%,b%,c%) > 0 THEN PRINT octavesequences%(a%,b%,c%)
    NEXT
   NEXT
  NEXT
 VDU 15
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 PRINT'" Change the number of sections of "
 PRINT" octave sequences?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 PRINT'" How many different sections of"
 INPUT " octave sequences are there "octavesections%
 ENDIF
 IF octavesections% > 1 THEN
 PRINT'" Change the starting point of"
  PRINT" any sections?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 INPUT'" How many "z%
  FOR count% = 1 TO z%
 PRINT'" section ";count%;" is section "
 INPUT y%
   PRINT'" this section now begins at note number "
   INPUT x%
   octavesequences%(y%,0,0) = x%
  NEXT
 ENDIF
 ENDIF
 :
 PRINT'" Make changes to the actual octave"
 PRINT" sequences?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 FOR count% = 1 TO octavesections%
 PRINT'" Any changes to section ";count%
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
  FOR pitch% = 0 TO 47
   entry$ = "n"
   IF pitch% MOD 4 = 0 AND grid$<>"s" THEN entry$ = "y"
   IF (pitch%-2)MOD4 = 0 THEN entry$ = "y"
   IF (pitch%-1)MOD2 = 0 AND grid$ = "e" THEN entry$ = "y"
   IF entry$ = "y" THEN
  PRINT'" changes in section ";count%;" to ";
  COLOUR 3 : PRINT pitchnames$(pitch%) : COLOUR 0
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
     PRINT '"In section ";count%;" the sequence of octaves for ";
    COLOUR 3 : PRINT pitchnames$(pitch%)
   COLOUR 0 : PRINT "has how many elements "
   INPUT e%
   PRINT""
   octavesequences%(count%,pitch%+1,0) = e%
   FOR counter% = 1 TO 11
    octavesequences%(count%,pitch%+1,counter%) = 0
   NEXT
   FOR counter% = 1 TO e%
    PRINT " element ";counter%;
    INPUT " is octave "o%
    octavesequences%(count%,pitch%+1,counter%) = o%
   NEXT
  ENDIF
  ENDIF
 NEXT
 ENDIF
 NEXT
 ENDIF
 ENDIF
 :
 CLS
 PRINT'" Make changes to transposition levels?"
 PRINT'" Currently"
 FOR a% = 1 TO transpositionsections%
  PRINT'" section ";a%;". ";transpositionsequences%(a%,1)/4;" semitones starting at note number ";transpositionsequences%(a%,0)
 NEXT
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
  ENDCASE
 IF do$ = "y" THEN
 PRINT'" Change the number of sections "
 PRINT" of transposition levels?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
  ENDCASE
 IF do$ = "y" THEN
 PRINT'" How many different sections of"
 INPUT" transposition are there "transpositionsections%
 ENDIF
 IF transpositionsections% > 1 THEN
 PRINT'" Change the starting point of"
 PRINT" any sections?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
  ENDCASE
 IF do$ = "y" THEN
 INPUT'" How many "z%
 FOR count% = 1 TO z%
 PRINT'" Section ";count%;" is section "
 INPUT y%
  PRINT'" this section now begins at "
  INPUT " note number "n%
  transpositionsequences%(y%,0) = n%
 NEXT
 ENDIF
 PRINT'" Change the degree of transposition"
 PRINT" of any sections?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
  ENDCASE
 IF do$ = "y" THEN
 INPUT'" How many "z%
 FOR count% = 1 TO z%
  PRINT'" Section ";count%;" is section "
 INPUT y%
  PRINT'" This section now transposes"
  PRINT" up/down by how many ";

  CASE grid$ OF
   WHEN "e" : PRINT "eighthtones" : INPUT " (+/- 1 etc) "x%
              transpositionsequences%(y%,1) = x%
   WHEN "q" : PRINT "quartertones" : INPUT " (+/- 1 etc) "x%
              transpositionsequences%(y%,1) = x% * 2
   WHEN "s" : PRINT "semitones" : INPUT " (+/- 1 etc) "x%
              transpositionsequences%(y%,1) = x% * 4
  ENDCASE
 NEXT
 ENDIF

 ENDIF
 ENDIF
 :
 CLS
 PRINT'" Make changes to the contour sequences?"
  PRINT'" Currently"
  FOR a% = 1 TO contoursections%
   FOR b% = 2 TO contoursequences%(a%,1)+1
    IF b% = 2 THEN PRINT'" section ";a%
    PRINT contoursequences%(a%,b%)
   NEXT
  NEXT
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 PRINT'" Change the number of sections?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 PRINT'" How many different sections of "
 INPUT " contour sequences are there "contoursections%
 ENDIF
 IF contoursections%>1 THEN
 PRINT'" Change the starting point"
 PRINT" of any sections?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 INPUT'" How many "z%
  FOR count% = 1 TO z%
 PRINT'" Section ";count%;" is section "
 INPUT y%
   PRINT'" This section"
   INPUT " begins at note number "n%
   contoursequences%(y%,0) = n%
  NEXT
 ENDIF
 ENDIF
 :
 PRINT'" Make changes to any contours?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 FOR count% = 1 TO contoursections%
 PRINT'" Change section ";count%;"?"
 CASE GET$ OF
  WHEN "Y","y","+" : do$ = "y"
  OTHERWISE do$ = "n"
 ENDCASE
 IF do$ = "y" THEN
 PRINT'" In section ";count%;
 INPUT " there are how many contours "c%
 contoursequences%(count%,1) = c%
 PRINT""
 FOR counter% = 1 TO c%
 PRINT " number ";counter%;
 INPUT " is contour "contoor%
 contoursequences%(count%,counter%+1) = contoor%
 NEXT
 ENDIF
 NEXT
 ENDIF
 ENDIF
 :
 PROCdeletesections
 REM this deletes info about sections which existed in
 REM previous versions of the string
 :
 contoursize% = 0 : seriesnote% = 1 : samplenote% = 0
 contoursequence% = 1 : transpositionsequence% = 1
 octavesequence% = 1 : transpositionsequences%(1,1) = 0
 contourloop% = 0 : octaveloop%() = 0
 :
 REPEAT
 seriesnote% += contoursize%
 IF seriesnote% >= contoursequences%(contoursequence%+1,0) AND contoursequences%(contoursequence%+1,0) <> 0 THEN
  contoursequence% += 1
  contourloop% = 0
 ENDIF
 :
 contourloop% += 1
 IF contourloop% > contoursequences%(contoursequence%,1) THEN contourloop% = 1
 contour% = contoursequences%(contoursequence%,contourloop%+1)
 contoursize% = contours%(contour%,0)
 :
 IF seriesnote% >= transpositionsequences%(transpositionsequence%+1,0) AND transpositionsequences%(transpositionsequence%+1,0) <> 0 THEN
  transpositionsequence% += 1
 ENDIF
 transposition% = transpositionsequences%(transpositionsequence%,1)
 :
 FOR count% = 1 TO contoursize%
  samplenote% += 1
  IF samplenote% > samplesize% THEN samplenote% = 1
  group%(count%) = sample%(samplenote%) + transposition%
 NEXT
 :
 IF seriesnote% >= octavesequences%(octavesequence%+1,0,0) AND octavesequences%(octavesequence%+1,0,0) <> 0 THEN
  octavesequence% += 1
  octaveloop%() = 0
 ENDIF
 :
 FOR count% = 1 TO contoursize%
  pitchclass% = group%(count%)
  REPEAT
   pitchclass% -= 48
  UNTIL pitchclass% < 51
  pitchclass% -= 2
  octaveloop%(pitchclass%) += 1
  IF octaveloop%(pitchclass%) > octavesequences%(octavesequence%,pitchclass%,0) THEN octaveloop%(pitchclass%) = 1
  oxtave% = octavesequences%(octavesequence%,pitchclass%,octaveloop%(pitchclass%))
  group%(count%) = (pitchclass%+2) + (48*oxtave%)
 NEXT
 :
 IF contoursize% > 1 THEN
  REPEAT
   FOR count% = 1 TO (contoursize%-1)
    IF group%(count%) >= group%(count%+1) THEN
     save% = group%(count%)
     group%(count%) = group%(count%+1)
     group%(count%+1) = save%
    ENDIF
   NEXT
   no% = 0
   FOR count% = 1 TO (contoursize%-1)
    IF group%(count%) > group%(count%+1) THEN no% = 1
   NEXT
  UNTIL no% = 0
 ENDIF
 :
 FOR count% = 1 TO contoursize%
  simplenote% = group%(contours%(contour%,count%))
  PROCconvertsimplenote
  pitches%((seriesnote%+count%)-1) = simplenote%
 NEXT
 :
 UNTIL ((seriesnote%+contoursize%)-1) >= numpitches%
 :
 FOR count% = 0 TO numpitches%-1 : pitches%(count%) = pitches%(count%+1) : NEXT
 PRINT'" Do you want to save this pitch string?"
 CASE GET$ OF
  WHEN "Y","y","+" : PROCsavepitchstring
  OTHERWISE
 ENDCASE
 :
 PROCinsertpitches
 :
 ENDPROC
 :
 REM************************************************
 :
 :
 DEF PROCdeletesections
 :
 FOR count% = 2 TO 50
 IF count% > octavesections% THEN
 octavesequences%(count%,0,0) = 0
 ENDIF
 NEXT
 :
 FOR count% = 2 TO 199
 IF count% > transpositionsections% THEN
 transpositionsequences%(count%,0) = 0
 ENDIF
 NEXT
 :
 FOR count% = 2 TO 50
 IF count% > contoursections% THEN
 contoursequences%(count%,0) = 0
 ENDIF
 NEXT
 :
 ENDPROC
 :
 REM**************************************************
 :
 DEF PROCyesno
 :
 CASE GET$ OF
  WHEN "Y","y" : on = 1
  OTHERWISE on = 2
 ENDCASE
 :
 ENDPROC
 :
 REM**************************************************
 :
 DEF PROCeditlayers
 :
 chanceoflayer%(1) = 1
 :
 PRINT'" Alter total length? [currently ";totallength%;"]"
 PROCyesno
 IF on = 1 THEN
 INPUT'" Total duration, in BEATS "totallength%
 ENDIF
 PRINT''" LAYERS -"
 PRINT'" Alter number of layers? [currently ";numlayers%;"]"
 PROCyesno
 IF on = 1 THEN
 INPUT'" How many layers "numlayers%
 ENDIF
 :
 PRINT'" Alter contribution proportions"
 PRINT" of the layers?"
 PROCyesno
 IF on = 1 THEN
 REM 1
 :
 PRINT'" Alter number of sections of"
 PRINT" proportions?"
 PROCyesno
 IF on = 1 THEN
   PRINT'" Piece is divided into how many sections"
  PRINT  " of different contribution-proportions "
  PRINT " [currently "; numlayersections%;"]"
  INPUT numlayersections%
 ENDIF
  :
  IF numlayersections% > 1 THEN
   :
 PRINT'" Alter starting points of sections?"
 PROCyesno
 IF on = 1 THEN
   FOR count% = 2 TO numlayersections%
 PRINT'" Alter start point of section ";count%;" [currently ";startoflayersection%(count%);"]"
 PROCyesno
 IF on = 1 THEN
    PRINT'" Section ";count%;" starts at beat number "
    INPUT startoflayersection%(count%)
 ENDIF
   NEXT
 ENDIF
  ENDIF
  :
 PRINT'" Alter any of the proportions?"
 PROCyesno
 IF on = 1 THEN
 REM 2
  FOR count% = 1 TO numlayersections%
 PRINT'" Alter proportions in section ";count%
 PROCyesno
 IF on = 1 THEN
 REM 3
   FOR count1% = 1 TO numlayers%
 PRINT'" Alter (section ";count%;") layer ";count1%;" proportions? [currently ";shareoflayers%(count%,count1%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 4
    PRINT '"In section ";count%;", layer ";count1%;" has "
    PRINT  "how many proportions?"
    INPUT shareoflayers%(count%,count1%)
 ENDIF : REM 4
   NEXT
 ENDIF : REM 3
  NEXT
 ENDIF : REM 2
  :
 ENDIF : REM 1
 :
 PRINT''" NUMBER OF ATTACKS, DURATIONS, MULTIPLIERS, RETURN AFTERS"
 FOR count% = 1 TO numlayers%
 PRINT'" Alterations to layer ";count%
 PROCyesno
 IF on = 1 THEN
 REM 5
 PRINT'" Alter number of attacks?"
 PROCyesno
 IF on = 1 THEN
 REM 6
 PRINT'" Alter whether controlled by sections/appearances?"
 PROCyesno
 IF on = 1 THEN
 REM 7
  PRINT'" In layer ";count%;" are the number of attacks controlled"
  PRINT " by sections or by appearance number (S/A)"
  PRINT " [currently ";attackscontrol$(count%);"]"
  CASE GET$ OF
   WHEN "S","s" :
    attackscontrol$(count%) = "S"
  OTHERWISE  attackscontrol$(count%) = "A"
 ENDCASE
 ELSE
  IF attackscontrol$(count%) = "" THEN attackscontrol$(count%) = "S" : REM default for added layers
 ENDIF : REM 7
 :
 IF attackscontrol$(count%) = "S" THEN
 REM 8
 IF numattackssections%(count%) = 0 THEN numattackssections%(count%) = 1 : REM new layers
 PRINT'" Alter number of sections? [currently ";numattackssections%(count%);"]"
 PROCyesno
 IF on = 1 THEN
 REM  9
    INPUT'" How many sections "numattackssections%(count%)
 ENDIF : REM 9
   IF numattackssections%(count%) > 1 THEN
 PRINT'" Alter starting point of any sections?"
 PROCyesno
 IF on = 1 THEN
 REM 10
    FOR count1% = 2 TO numattackssections%(count%)
 PRINT'" Alter starting point of section ";count1%;" currently [";startofattackssection%(count%,count1%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 11
     PRINT'" (layer ";count%;") section ";count1%;" starts at beat"
     INPUT startofattackssection%(count%,count1%)
 ENDIF : REM 11
    NEXT
 ENDIF : REM 10
   ENDIF
 PRINT'" Alter the number of attacks in layer ";count%
 PROCyesno
 IF on = 1 THEN
 REM 12
    :
    FOR count1% = 1 TO numattackssections%(count%)
 PRINT'" Alter attacks in section ";count1%;" [currently ";numattax%(count%,count1%,0);"-";numattax%(count%,count1%,1);"]"
 PROCyesno
 IF on = 1 THEN
 REM 13
     PRINT'" In layer ";count%;", section ";count1%;" the number"
     PRINT" of attacks varies between..."
     INPUT numattax%(count%,count1%,0)
     INPUT" and..."numattax%(count%,count1%,1)
 ENDIF : REM 13
    NEXT
 ENDIF : REM 12
 ENDIF : REM 8
    :
 IF attackscontrol$(count%) = "A" THEN
 REM 14
 PRINT'" Alter number of 'sections' of appearances? [currently ";numattackssections1%(count%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 15
   INPUT'" How many 'sections' of appearances "numattackssections1%(count%)
 ENDIF : REM 15
   IF numattackssections1%(count%) > 1 THEN
 PRINT'" Alter starting point of any sections?"
 PROCyesno
 IF on = 1 THEN
 REM 16
    FOR count1% = 2 TO numattackssections1%(count%)
 PRINT'" Alter starting point of section ";count1%;" [currently appearance ";startofattackssection1%(count%,count1%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 17
     PRINT'" (layer ";count%;") section ";count1%;" starts at appearance "
     INPUT startofattackssection1%(count%,count1%)
 ENDIF : REM 17
    NEXT
 ENDIF : REM 16
   ENDIF
   :
 PRINT'" Alter number of attacks in layer ";count%
 PROCyesno
 IF on = 1 THEN
 REM 18
   FOR count1% = 1 TO numattackssections1%(count%)
 PRINT'" Alter number of attacks in section ";count1%;" [currently ";numattax1%(count%,count1%,0);"-";numattax1%(count%,count1%,1);"]"
 PROCyesno
 IF on = 1 THEN
 REM 19
    PRINT'" In layer ";count%;", section ";count1%;" the number"
    PRINT" of attacks varies between..."
    INPUT numattax1%(count%,count1%,0)
    INPUT" and... "numattax1%(count%,count1%,1)
 ENDIF : REM 19
   NEXT
 ENDIF : REM 18
  ENDIF : REM 14
  ENDIF : REM 6
 :
 PRINT''" DURATIONS"
 PRINT'" Alter durations in layer ";count%
 PROCyesno
 IF on = 1 THEN
 REM 20
 :
 PRINT'" Alter whether durations in sections/appearances?"
 PROCyesno
 IF on = 1 THEN
 REM 21

 PRINT'" In layer ";count%;" are the unit durations controlled"
 PRINT" by sections or by appearance number (S/A)"
 PRINT " [currently ";durationscontrol$(count%);"]"
 CASE GET$ OF
  WHEN "S","s" :
   durationscontrol$(count%) = "S"
  OTHERWISE durationscontrol$(count%) = "A"
 ENDCASE
 ELSE
  IF durationscontrol$(count%) = "" THEN durationscontrol$(count%) = "S" : REM new layers default
 ENDIF : REM 21
 IF durationscontrol$(count%) = "S" THEN
 REM 22
  IF numdurationssections%(count%) = 0 THEN numdurationssections%(count%) = 1 : REM new layers
 PRINT'" Alter number of sections of durations? [currently ";numdurationssections%(count%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 23
   INPUT'" How many sections "numdurationssections%(count%)
 ENDIF : REM 23
   IF numdurationssections%(count%) > 1 THEN
 PRINT'" Alter starting point of sections?"
 PROCyesno
 IF on = 1 THEN
 REM 24
    FOR count1% = 2 TO numdurationssections%(count%)
 PRINT'" Alter starting point of section ";count1%;" [currently ";startofdurationssection%(count%,count1%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 25
     PRINT'" (layer ";count%;") section ";count1%;" starts at beat "
     INPUT startofdurationssection%(count%,count1%)
 ENDIF : REM 25
    NEXT
 ENDIF : REM 24
   ENDIF
   :
 PRINT'" Alter the unit durations?"
 PROCyesno
 IF on = 1 THEN
 REM 26
   FOR count1% = 1 TO numdurationssections%(count%)
 PRINT'" Alter the duration in section ";count1%;" [currently ";doorations%(count%,count1%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 27
    PRINT'" In layer ";count%;", section ";count1%;" the unit duration is"
    INPUT beats% : PROCalterbeats
    doorations%(count%,count1%) = beats%
 ENDIF : REM 27
   NEXT
 ENDIF : REM 26
 ENDIF : REM 22
 :
 IF durationscontrol$(count%) = "A" THEN
 REM 28
 PRINT'" Alter number of 'sections'? [currently ";numdurationssections1%(count%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 29
   INPUT'" How many 'sections' "numdurationssections1%(count%)
 ENDIF : REM 29
   IF numdurationssections1%(count%) > 1 THEN
 PRINT'" Alter starting point of 'sections'?"
 PROCyesno
 IF on = 1 THEN
 REM 30
    FOR count1% = 2 TO numdurationssections1%(count%)
 PRINT'" Alter section ";count1%;" [currently appearance ";startofdurationssection1%(count%,count1%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 31
     PRINT'" (layer ";count%;") section ";count1%;" starts at appearance "
     INPUT startofdurationssection1%(count%,count1%)
 ENDIF : REM 31
    NEXT
 ENDIF : REM 30
   ENDIF
 PRINT'" Alter the unit durations?"
 PROCyesno
 IF on = 1 THEN
 REM 32
  FOR count1% = 1 TO numdurationssections1%(count%)
 PRINT'" Alter section ";count1%;" [currently ";doorations1%(count%,count1%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 33
   PRINT'" In layer ";count%;", section ";count1%;" the unit duration is "
   INPUT doorations1%(count%,count1%)
 ENDIF : REM 33
  NEXT
 ENDIF : REM 32
 ENDIF : REM 28
 ENDIF : REM 20
 :
PRINT'" Alter multiplication of durations?"
 PROCyesno
 IF on = 1 THEN
 REM 34
 PRINT'" Do you want the unit duration to be multiplied"
 PRINT " by a given series of values (Y/N) [currently ";multiplier$(count%);"]"
 CASE GET$ OF
  WHEN "Y","y" :
   multiplier$(count%) = "Y"
   PRINT'" starting fresh at each appearance or irrespective (F/I) "
   PRINT " [currently ";multipliermode$(count%);"]"
   CASE GET$ OF
    WHEN "F","f" :
    multipliermode$(count%) = "F"
   OTHERWISE multipliermode$(count%) = "I"
   ENDCASE
  :
  PRINT'" How many values [currently ";numvalues%(count%);"]"
  INPUT numvalues%(count%)
  FOR count1% = 1 TO numvalues%(count%)
   PRINT'" value ";count1%;" is [currently ";values(count%,count1%);"]"
   INPUT values(count%,count1%)
   NEXT
  OTHERWISE multiplier$(count%) = "N"
  ENDCASE
  ELSE
  IF multiplier$(count%) = "" THEN multiplier$(count%) = "N" : REM default for new layers
 ENDIF : REM 34
 :
 PRINT'" Alter control over reoccurence of layers?"
 PROCyesno
 IF on = 1 THEN
 REM 35
 IF numlayerOKsects%(count%) = 0 THEN word$ = "No" ELSE word$ = "Yes"
 PRINT'" Do you want this layer to reoccur according"
 PRINT " to minimum and maximum intervals (eg to"
 PRINT " control phrase-lengths)? [currently ";word$;"]"
 CASE GET$ OF
  WHEN "Y","y" :
 PRINT'" Alter number of sections? [currently ";numlayerOKsects%(count%);"]"
 PROCyesno
 IF on = 1 THEN
 REM 36
   INPUT'" How many sections of this "numlayerOKsects%(count%)
 ENDIF : REM 36
   FOR count1% = 1 TO numlayerOKsects%(count%)
 PRINT'" Any alteration to section ";count1%
 PROCyesno
 IF on = 1 THEN
 REM 37
 PRINT'" Alter the starting point? [currently ";layersOK%(count%,count1%,0);"]"
 PROCyesno
 IF on = 1 THEN
 REM 38
    IF numlayerOKsects%(count%) > 1 THEN
     PRINT'" section ";count1%;" begins at beat "
     INPUT x%
    ELSE x% = 0
    ENDIF
 layersOK%(count%,count1%,0) = x%
 ENDIF : REM 38
 PRINT'" Alter the controlling intervals?"
 PROCyesno
 IF on = 1 THEN
 REM 39
    PRINT'" in this section the layer should NOT reoccur"
    PRINT" until at least how many beats from the"
    PRINT" end of its previous occurence? [currently ";layersOK%(count%,count1%,1);"]"
    INPUT y%
    PRINT'" but SHOULD be made to reoccur after how "
    PRINT" many beats from the end of its previous"
    PRINT" occurence? [currently ";layersOK%(count%,count1%,2);"]"
    INPUT z%

    layersOK%(count%,count1%,1) = y%
    layersOK%(count%,count1%,2) = z%
 ENDIF : REM 39
 ENDIF : REM 37
   NEXT
  OTHERWISE numlayerOKsects%(count%) = 0
 ENDCASE
 ENDIF : REM 35
 :
 ENDIF : REM 5
 :
 NEXT
 :

 :
 PROClayeredattacks
 :
 ENDPROC
 :
 REM**************************************************
 :
 DEF PROCsavelayers
 :
*Dir SDFS::RISCOSpi.$.CAC.Files
 firstnaming$ = "n"
 CLS
 IF filenamelyr$ = "" THEN
 INPUT'" filename "filenamelyr$
 firstnaming$ = "y"
 ENDIF
 IF firstnaming$ = "n" THEN
 PRINT'" as '";filenamelyr$;"'?"
 CASE GET$ OF
  WHEN "N","n" : INPUT'" filename "filenamelyr$
  OTHERWISE
 ENDCASE
 ENDIF
 :
 channel = OPENOUT filenamelyr$
 PRINT#channel, totallength%
 PRINT#channel, numlayers%
 PRINT#channel, numlayersections%
 FOR a% = 0 TO numlayersections%
  PRINT#channel, startoflayersection%(a%)
 NEXT
 FOR a% = 0 TO numlayersections%
  FOR b% = 0 TO numlayers%
  PRINT#channel, shareoflayers%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  PRINT#channel, attackscontrol$(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  PRINT#channel, numattackssections%(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numattackssections%(a%)
   PRINT#channel, startofattackssection%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numattackssections%(a%)
   FOR c% = 0 TO 1
    PRINT#channel, numattax%(a%,b%,c%)
   NEXT
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  PRINT#channel, numattackssections1%(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numattackssections1%(a%)
   PRINT#channel, startofattackssection1%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numattackssections1%(a%)
   FOR c% = 0 TO 1
    PRINT#channel, numattax1%(a%,b%,c%)
   NEXT
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
 PRINT#channel, durationscontrol$(a%)
 NEXT
 FOR a% = 0 TO numlayers%
 PRINT#channel, numdurationssections%(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numdurationssections%(a%)
    PRINT#channel, startofdurationssection%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numdurationssections%(a%)
    PRINT#channel, doorations%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
    PRINT#channel, numdurationssections1%(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numdurationssections1%(a%)
    PRINT#channel, doorations1%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numdurationssections1%(a%)
    PRINT#channel, startofdurationssection1%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
    PRINT#channel, multiplier$(a%)
 NEXT
 FOR a% = 0 TO numlayers%
    PRINT#channel, multipliermode$(a%)
 NEXT
 FOR a% = 0 TO numlayers%
    PRINT#channel, numvalues%(a%)
 NEXT
  FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numvalues%(a%)
    PRINT#channel, values(a%,b%)
  NEXT
 NEXT
  FOR a% = 0 TO numlayers%
    PRINT#channel, numlayerOKsects%(a%)
 NEXT
  FOR a% = 0 TO numlayers%
   FOR b% = 0 TO numlayerOKsects%(a%)
    FOR c% = 0 TO 2
     PRINT#channel, layersOK%(a%,b%,c%)
   NEXT
  NEXT
 NEXT
 :
 CLOSE#channel
 *NoDir
 :
 ENDPROC
 :
 REM****************************************************
 :
 DEF PROCloadlayers
 :
*Dir SDFS::RISCOSpi.$.CAC.Files
 INPUT'" filename "filenamelyr$
 channel = OPENIN filenamelyr$
 REPEAT
 INPUT#channel, totallength%
 INPUT#channel, numlayers%
 INPUT#channel, numlayersections%
 FOR a% = 0 TO numlayersections%
  INPUT#channel, startoflayersection%(a%)
 NEXT
 FOR a% = 0 TO numlayersections%
  FOR b% = 0 TO numlayers%
  INPUT#channel, shareoflayers%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  INPUT#channel, attackscontrol$(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  INPUT#channel, numattackssections%(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numattackssections%(a%)
   INPUT#channel, startofattackssection%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numattackssections%(a%)
   FOR c% = 0 TO 1
    INPUT#channel, numattax%(a%,b%,c%)
   NEXT
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  INPUT#channel, numattackssections1%(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numattackssections1%(a%)
   INPUT#channel, startofattackssection1%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numattackssections1%(a%)
   FOR c% = 0 TO 1
    INPUT#channel, numattax1%(a%,b%,c%)
   NEXT
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
 INPUT#channel, durationscontrol$(a%)
 NEXT
 FOR a% = 0 TO numlayers%
 INPUT#channel, numdurationssections%(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numdurationssections%(a%)
    INPUT#channel, startofdurationssection%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numdurationssections%(a%)
    INPUT#channel, doorations%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
   INPUT#channel, numdurationssections1%(a%)
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numdurationssections1%(a%)
    INPUT#channel, doorations1%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numdurationssections1%(a%)
    INPUT#channel, startofdurationssection1%(a%,b%)
  NEXT
 NEXT
 FOR a% = 0 TO numlayers%
    INPUT#channel, multiplier$(a%)
 NEXT
 FOR a% = 0 TO numlayers%
    INPUT#channel, multipliermode$(a%)
 NEXT
 FOR a% = 0 TO numlayers%
    INPUT#channel, numvalues%(a%)
 NEXT
  FOR a% = 0 TO numlayers%
  FOR b% = 0 TO numvalues%(a%)
    INPUT#channel, values(a%,b%)
  NEXT
 NEXT
  FOR a% = 0 TO numlayers%
    INPUT#channel, numlayerOKsects%(a%)
 NEXT
  FOR a% = 0 TO numlayers%
   FOR b% = 0 TO numlayerOKsects%(a%)
    FOR c% = 0 TO 2
    INPUT#channel, layersOK%(a%,b%,c%)
   NEXT
  NEXT
 NEXT
 UNTIL EOF#channel
 CLOSE#channel
 *NoDir
 :
 ENDPROC
 :
 REM************************************************
 :
 DEF PROCseriesamplitudes
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,69,73,45) ELSE PROCwindow(20,69,73,42)
 :
 IF ampoptions$ = "y" THEN
 PRINT'" Create a new group, edit current group,"
 PRINT" or load a file (N/E/F)"
 CASE GET$ OF
  WHEN "N","n" :
   filenameamps$ = ""
   PRINT'" from a sample of amplitudes or"
   PRINT" according to attacks or by note"
   PRINT" numbers (S/A/N)"
   CASE GET$ OF
    WHEN "S","s" : ampmethod$ = "sample" : PROCnewamps
    WHEN "A","a" : ampmethod$ = "attacks" : PROCnewamps
    WHEN "N","n" : ampmethod$ = "notenumber" : PROCnewamps
    OTHERWISE VDU 7 : PROCseriesamplitudes
   ENDCASE
  WHEN "E","e" : PROCeditamps
  WHEN "F","f" : PROCloadamps : PROCeditamps
  OTHERWISE VDU 7 : PROCseriesamplitudes
 ENDCASE
 :
 PRINT'" Save these settings?"
 CASE GET$ OF
  WHEN "Y","y" : PROCsaveamps
  OTHERWISE
 ENDCASE
 :
 PROCrunamps
 :
  PRINT'" Re-order amplitudes randomly?"
 CASE GET$ OF
  WHEN "Y","y" : PROCreorderamps
  OTHERWISE
  ENDCASE
 :
 numamplitudes% = manyattacks% : PROCinsertamplitudes
 :
 ELSE PROCsimpleamps
 ENDIF
 :
 ENDPROC
 :
 REM***************************************

DEF PROCsimpleamps
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,69,73,45) ELSE PROCwindow(20,69,73,42)
 INPUT'" How many amplitudes "numamplitudes%
 IF numamplitudes% = 0 THEN numamplitudes% = 1
 :
 IF numamplitudes% = 1 THEN
  INPUT'" the amplitude is: "dyn$
  PROCconvertdyn
  amplitudes%(0) = dyn%
 ELSE
  PRINT'" Are all the amplitudes the same?"
  CASE GET$ OF
  WHEN "N","n","2" :
  FOR count% = 0 TO (numamplitudes%-1)
  PRINT'" amplitude ";count%+1;" is: "
IF count% > 0 THEN PRINT " (0 = previous) "

  INPUT dyn$

IF dyn$ = "" THEN
 dyn$ = prevdyn$
 COLOUR 3 : PRINT dyn$
 wait$ = INKEY$(20) : COLOUR 0
ENDIF

prevdyn$ = dyn$

  PROCconvertdyn
  amplitudes%(count%) = dyn%
  NEXT
  OTHERWISE
  INPUT'" the amplitude is: "dyn$
  PROCconvertdyn
  FOR count% = 0 TO (numamplitudes%-1) : amplitudes%(count%) = dyn% : NEXT
  ENDCASE
 ENDIF
 :
 REM function can feed amplitudes similarly into amplitudes%()
 :
 ampmethod$ = "sample"
 PROCinsertamplitudes
 :
 ENDPROC
 :
 *************************************************************************
 :
 DEF PROCnewamps
 :
 CASE ampmethod$ OF
  WHEN "attacks" :
   PRINT'" Dynamics determined by the preceding"
   PRINT" attack intervals, the succeeding ones,     "
   PRINT" or both (P/S/B)"
   CASE GET$ OF
    WHEN "P","p" : prepost$ = "P"
    WHEN "S","s" : prepost$ = "S"
    OTHERWISE prepost$ = "B"
   ENDCASE
 CLS
  PRINT'" How many different 'layers' of dynamics?"
  PRINT'" (NB layers inputted later override earlier ones;"
  PRINT" existing dynamics remain unchanged if their"
   PRINT" interval is not included, or if the interval is"
   PRINT" set at 0 - 0)"
   INPUT dynlayers%
 :
  FOR count% = 1 TO dynlayers%
   IF prepost$ = "P" OR prepost$ = "B" THEN
    PRINT'" In layer ";count%;" the preceding interval "
    PRINT " is between how many beats..."
    INPUT dynlayers%(count%,0)
    PRINT'" and how many beats..."
    INPUT dynlayers%(count%,1)
    PRINT'" and the dynamic is "
    INPUT dyn$
    PROCconvertdyn : dynlayers%(count%,2) = dyn%
   ENDIF
 :
   IF prepost$ = "S" OR prepost$ = "B" THEN
    PRINT'" In layer ";count%;" the succeeding interval "
    PRINT " is between how many beats..."
    INPUT dynlayers%(count%,3)
    PRINT'" and how many beats..."
    INPUT dynlayers%(count%,4)
    PRINT'" and the dynamic is "
    INPUT dyn$
    PROCconvertdyn : dynlayers%(count%,5) = dyn%
   ENDIF
  NEXT
 :
 WHEN "notenumber" :
  INPUT'" How many elements in the (recycling) pattern "dynnumbers%
  FOR count% = 1 TO dynnumbers%
   PRINT'" Element ";count%;" places dynamics ";count%;" and ";count%+1
   PRINT" how many notes apart?"
   INPUT dynnumbers%(count%)
  NEXT
  PRINT" and the dynamic for these notes is "
  INPUT dynnumbers$
 :
 WHEN "sample" :
  INPUT'" Total number of amplitudes "manyattacks%
  INPUT " Number of amplitudes in the sample "ampsample%
  FOR count% = 0 TO (ampsample%-1)
   PRINT'" Element ";count%+1;" in the sample is "
   INPUT dyn$
   PROCconvertdyn : ampsample%(count%) = dyn%
  NEXT
 :
 ENDCASE
 :
 ENDPROC
 :
 REM*********************************************
 :
 DEF PROCconvertdyn
 :
 CASE dyn$ OF
  WHEN "0" : dyn% = 0
  WHEN "ppp" : dyn% = 1
  WHEN "pp" : dyn% = 2
  WHEN "p" : dyn% = 3
  WHEN "mp" : dyn% = 4
  WHEN "mf" : dyn% = 5
  WHEN "f" : dyn% = 6
  WHEN "ff" : dyn% = 7
  WHEN "fff" : dyn% = 8
 ENDCASE
 ENDPROC
 :
 REM*********************************************
 :
 DEF PROCrunamps
 :
 IF ampmethod$ = "attacks" OR ampmethod$ = "notenumber" THEN
 INPUT'" The dynamics are to be read into which voice? "voice%
 voice% -= 1
 INPUT'" Starting at bar "copystartbar%
 INPUT"             beat "beats%
 PROCalterbeats : copystartbeat%   = beats%
 startat% = (copystartbar%*10^3)+beats%
 INPUT'" Ending at bar "copyendbar%
 INPUT "           beat "beats%
 PROCalterbeats : copyendbeat% = beats%
 :
 value% = (copystartbar%*10^3)+copystartbeat%
 IF value% <= array%(0,0,voice%)DIV10^3 THEN
  startatcell% = 0
 ELSE
 PROCsearch(value%)
 startatcell% = startcell%
 ENDIF
 value% = (copyendbar%*10^3)+copyendbeat%
 IF value% >= array%(numusedcells%(voice%)-1,0,voice%)DIV10^3 THEN
  endatcell% = numusedcells%(voice%) - 1
 ELSE
 PROCsearch(value%)
 IF shunt$ = "N" THEN endatcell% = startcell% ELSE endatcell% = startcell% - 1
 ENDIF
 :
 manyattacks% = endatcell% - startatcell% + 1
 REM create 'gap' between beat-of-bar and first actual attack
 carrybars% = (array%(startatcell%,0,voice%)DIV10^6)-copystartbar%
 carrybeats% = ((array%(startatcell%,0,voice%)DIV10^3)MOD10^3)-copystartbeat%
 attacks1%(0) = (carrybars%*960)+carrybeats%
 :
 FOR count% = 0 TO (manyattacks%-1)
  IF count% > 0 THEN
   carrybars% = (array%(startatcell%+count%,0,voice%)DIV10^6)-(array%(startatcell%+count%-1,0,voice%)DIV10^6)
   carrybeats% = ((array%(startatcell%+count%,0,voice%)DIV10^3)MOD10^3)-((array%(startatcell%+count%-1,0,voice%)DIV10^3)MOD10^3)
   attacks1%(count%) = attacks1%(count%-1) + ((carrybars%*960)+carrybeats%)
  ENDIF
 :
  pitches%(count%+1) = array%(startatcell%+count%,0,voice%)MOD10^3
  durations%(count%+1) = (array%(startatcell%+count%,1,voice%)DIV10)MOD10^3
  amplitudes%(count%+1) = (array%(startatcell%+count%,1,voice%))MOD10
  envelopes%(count%+1) = (array%(startatcell%+count%,2,voice%))DIV10^2
  glissandos%(count%+1) = (array%(startatcell%+count%,1,voice%)DIV10^4)
  inflections%(count%+1) = array%(startatcell%+count%,2,voice%)MOD10^2
 NEXT
 ENDIF
 :
 CASE ampmethod$ OF
  WHEN "attacks" :
   FOR count% = 0 TO manyattacks%-1
    FOR count1% = 1 TO dynlayers%
     IF count% > 0 THEN
      IF prepost$ = "P" OR prepost$ = "B" THEN
       IF attacks1%(count%)-attacks1%(count%-1)>=dynlayers%(count1%,0) AND attacks1%(count%)-attacks1%(count%-1)<=dynlayers%(count1%,1) THEN amplitudes%(count%+1) = dynlayers%(count1%,2)
       ENDIF
      ENDIF
      IF prepost$ = "S" OR prepost$ = "B" THEN
       IF attacks1%(count%+1)-attacks1%(count%)>=dynlayers%(count1%,3)ANDattacks1%(count%+1)-attacks1%(count%)<=dynlayers%(count1%,4) THEN amplitudes%(count%+1) = dynlayers%(count1%,5)
       ENDIF
    NEXT
   NEXT
 :
 WHEN "notenumber" :
  count% = 1 : count1% = 0
  dyn$ = dynnumbers$ : PROCconvertdyn
  REPEAT
   count1% += 1
   IF count1% > dynnumbers% THEN count1% = 1
   amplitudes%(count%) = dyn%
   count% += dynnumbers%(count1%)
  UNTIL count% > manyattacks%
 :
 WHEN "sample" :
  count% = 1 : count1% = 1
  REPEAT
   amplitudes%(count%-1) = ampsample%(count1%-1)
   count% += 1 : count1% += 1
   IF count1% > ampsample% THEN count1% = 1
  UNTIL count% > manyattacks%
 :
 ENDCASE
 :
 ENDPROC
 :
 REM******************************************************
 :
 DEF PROCreorderamps
 :
 FOR count% = 0 TO manyattacks%-1
  REPEAT
   x% = RND(manyattacks%)
x% = x%-1
IF amplitudes%(x%) = 0 THEN thiscell$ = "done" ELSE thiscell$ = "available"
  UNTIL thiscell$ = "available"
  amplitudes1%(count%) = amplitudes%(x%)
  amplitudes%(x%) = 0
 NEXT
 amplitudes%() = amplitudes1%()
 :
 ENDPROC
 :
 REM*****************************************************
 :
 DEF PROCeditamps
 :
 CASE ampmethod$ OF
  WHEN "attacks" :
   PRINT'" Alter whether dynamics determined by"
   PRINT" preceding, succeeding intervals or both?"
   PROCyesno
   IF on = 1 THEN
   PRINT'" Dynamics determined by the preceding"
   PRINT" attack intervals, the succeeding ones,     "
   PRINT" or both (P/S/B)"
   CASE GET$ OF
    WHEN "P","p" : prepost$ = "P"
    WHEN "S","s" : prepost$ = "S"
    OTHERWISE prepost$ = "B"
   ENDCASE
   ENDIF
 CLS
   PRINT'" Alter number of 'layers'?"
   PROCyesno
   IF on = 1 THEN
  PRINT'" How many different 'layers' of dynamics?"
  PRINT'" (NB layers inputted later override earlier ones;"
  PRINT" existing dynamics remain unchanged if their"
   PRINT" interval is not included, or if the interval is"
   PRINT" set at 0 - 0)"
   INPUT dynlayers%
   ENDIF
 :
   PRINT'" Alter any of the layers?"
   PROCyesno
   IF on = 1 THEN
  FOR count% = 1 TO dynlayers%
    PRINT'" Alter layer ";count%
   PROCyesno
   IF on = 1 THEN
   IF prepost$ = "P" OR prepost$ = "B" THEN
    PRINT'" In layer ";count%;" the preceding interval "
    PRINT " is between how many beats..."
    INPUT dynlayers%(count%,0)
    PRINT'" and how many beats..."
    INPUT dynlayers%(count%,1)
    PRINT'" and the dynamic is "
    INPUT dyn$
    PROCconvertdyn : dynlayers%(count%,2) = dyn%
   ENDIF
 :
   IF prepost$ = "S" OR prepost$ = "B" THEN
    PRINT'" In layer ";count%;" the succeeding interval "
    PRINT " is between how many beats..."
    INPUT dynlayers%(count%,3)
    PRINT'" and how many beats..."
    INPUT dynlayers%(count%,4)
    PRINT'" and the dynamic is "
    INPUT dyn$
    PROCconvertdyn : dynlayers%(count%,5) = dyn%
   ENDIF
  ENDIF
  NEXT
  ENDIF
 :
 WHEN "notenumber" :
   PRINT'" Alter number of elements in the pattern?"
   PROCyesno
   IF on = 1 THEN
  INPUT'" How many elements in the (recycling) pattern "dynnumbers%
   ENDIF
  FOR count% = 1 TO dynnumbers%
  PRINT'" Alter element ";count%
  PROCyesno
  IF on =1 THEN
   PRINT'" Element ";count%;" places dynamics ";count%;" and ";count%+1
   PRINT" how many notes apart?"
   INPUT dynnumbers%(count%)
   ENDIF
  NEXT
   PRINT'" Alter the dynamic?"
  PROCyesno
  IF on =1 THEN
  PRINT" and the dynamic for these notes is "
  INPUT dynnumbers$
  ENDIF
 :
 WHEN "sample" :
  PRINT'" Alter total number of amplitudes?"
  PROCyesno
  IF on =1 THEN
  INPUT'" Total number of amplitudes "manyattacks%
   ENDIF
  PRINT'" Alter number of amplitudes in the sample?"
  PROCyesno
  IF on =1 THEN
  INPUT " Number of amplitudes in the sample "ampsample%
   ENDIF
  PRINT'" Alter the sample?"
  PROCyesno
  IF on =1 THEN
  FOR count% = 0 TO ampsample%-1
  PRINT'" Alter element ";count%+1
  PROCyesno
  IF on =1 THEN
   PRINT'" Element ";count%+1;" in the sample is "
   INPUT dyn$
   PROCconvertdyn : ampsample%(count%) = dyn%
  ENDIF
  NEXT
  ENDIF
 :
 ENDCASE
 :
 ENDPROC
 :
 REM***************************************************
 :
 DEF PROCsaveamps
 :
 :
 *Dir SDFS::RISCOSpi.$.CAC.Files
 firstnaming$ = "n"
 CLS
 IF filenameamps$ = "" THEN
 INPUT'" filename "filenameamps$
 firstnaming$ = "y"
 ENDIF
 IF firstnaming$ = "n" THEN
 PRINT'" as '";filenameamps$;"'?"
 CASE GET$ OF
  WHEN "N","n" : INPUT'" filename "filenameamps$
  OTHERWISE
 ENDCASE
 ENDIF
 :
 channel = OPENOUT filenameamps$
 PRINT#channel, ampmethod$
 IF ampmethod$ = "attacks" THEN
 PRINT#channel, prepost$
 PRINT#channel, dynlayers%
 ENDIF
 IF ampmethod$ = "notenumber" THEN
 PRINT#channel, dynnumbers%
 PRINT#channel, dynnumbers$
 ENDIF
 IF ampmethod$ = "sample" THEN
 PRINT#channel, manyattacks%
 PRINT#channel, ampsample%
 ENDIF
 IF ampmethod$ = "attacks" THEN
 FOR a% = 0 TO 12
 FOR b% = 0 TO 5
 PRINT#channel, dynlayers%(a%,b%)
 NEXT
 NEXT
 ENDIF
 IF ampmethod$ = "notenumber" THEN
 FOR a% = 0 TO 99
 PRINT#channel, dynnumbers%(a%)
 NEXT
 ENDIF
 IF ampmethod$ = "sample" THEN
 FOR a% = 0 TO 49
 PRINT#channel, ampsample%(a%)
 NEXT
  ENDIF
 :
 CLOSE#channel
 *NoDir
 :
 ENDPROC
 :
 REM***********************************
 :
 DEF PROCloadamps
 :
 :
 *Dir SDFS::RISCOSpi.$.CAC.Files
 INPUT'" filename "filenameamps$
 channel = OPENIN filenameamps$
 REPEAT
  INPUT#channel, ampmethod$
 IF ampmethod$ = "attacks" THEN
  INPUT#channel, prepost$
  INPUT#channel, dynlayers%
 ENDIF
 IF ampmethod$ = "notenumber" THEN
  INPUT#channel, dynnumbers%
  INPUT#channel, dynnumbers$
 ENDIF
 IF ampmethod$ = "sample" THEN
  INPUT#channel, manyattacks%
  INPUT#channel, ampsample%
 ENDIF
 IF ampmethod$ = "attacks" THEN
  FOR a% = 0 TO 12
  FOR b% = 0 TO 5
  INPUT#channel, dynlayers%(a%,b%)
  NEXT
  NEXT
 ENDIF
 IF ampmethod$ = "notenumber" THEN
  FOR a% = 0 TO 99
  INPUT#channel, dynnumbers%(a%)
  NEXT
 ENDIF
 IF ampmethod$ = "sample" THEN
  FOR a% = 0 TO 49
  INPUT#channel, ampsample%(a%)
  NEXT
 ENDIF
 :
 UNTIL EOF#channel
 CLOSE#channel
 *NoDir
 :
 ENDPROC
 :
 REM*********************************
 :
 DEF PROCbeatnumbers
 :
 amount% = 10
 IF beatnum_diff$ = "num" THEN
  IF beatunits$ = "big" THEN
   PRINT (array%(startcell%,0,voice%)DIV10^3)MOD10^3
  ELSE beatnum = ((array%(startcell%,0,voice%)DIV10^3)MOD10^3)/beatfactor%
  IF beatnum MOD 1 > 0 THEN
   beatnum = beatnum*10
   beatnum% = beatnum DIV 1
   PRINT beatnum%/amount%
  ELSE PRINT beatnum
  ENDIF
  ENDIF
 ELSE
  beatdiff% = ((array%(startcell%+1,0,voice%)DIV10^3)MOD10^3)-((array%(startcell%,0,voice%)DIV10^3)MOD10^3)
  beatdiff%+=(((array%(startcell%+1,0,voice%)DIV10^6)-(array%(startcell%,0,voice%)DIV10^6))*960)
  :
   IF beatdiff% > 0 THEN
   IF beatunits$ = "big" THEN
    PRINT beatdiff%
   ELSE
    beatdiff = beatdiff%/beatfactor%
    IF beatdiff MOD 1 > 0 THEN
     beatdiff = beatdiff*10
     beatdiff% = beatdiff DIV 1
     PRINT beatdiff%/amount%
    ELSE PRINT beatdiff%/beatfactor%
    ENDIF
   ENDIF
   ENDIF
  :
  ENDIF
 ENDPROC
 :
 REM****************************************************
 :
 DEF PROCextract
 :
 counter% = -1 : attacks1%() = 0 : countt% = -1 : endcell% = manyattacks%
 IF extractmode$ = "random" THEN numb% = RND(higher%-lower%+1)+lower%-2
 REPEAT
 countt% += 1
 extract$ = "n"
 :
 CASE extractmode$ OF
  WHEN "pitchclass" :
   attempts% = 0
   REPEAT
    attempts% += 1
 :
    IF extractinfo%(attempts%) = array%(startatcell%+countt%,0,voice%)MOD10^3 THEN extract$ = "y"
   UNTIL extract$ = "y" OR attempts% = npitches%
  WHEN "band" :
   attempts% = 0 : top$ = "n" : bottom$ = "n"
   theoctave% = array%(startatcell%+countt%,0,voice%)MOD10
   thepitch% = (array%(startatcell%+countt%,0,voice%)DIV10^2)MOD10
   theaccid% = (array%(startatcell%+countt%,0,voice%)DIV10)MOD10
   REPEAT
    attempts% += 1
    testoctave% = extractinfo%(attempts%)MOD10
    testpitch% = extractinfo%(attempts%)DIV10^2
    testaccid% = (extractinfo%(attempts%)DIV10)MOD10
    IF ((attempts%/2)*10)MOD10 > 0 THEN
     IF theoctave% >= testoctave% THEN bottom$ = "y" ELSE bottom$ = "n"
     IF bottom$ = "y" AND theoctave% = testoctave% THEN
      IF thepitch% >= testpitch% THEN bottom$ = "y" ELSE bottom$ = "n"
     ENDIF
     IF bottom$ = "y" AND theoctave% = testoctave% AND thepitch% = testpitch% THEN
      IF theaccid% >= testaccid% THEN bottom$ = "y" ELSE bottom$ = "n"
     ENDIF
    ELSE
     IF theoctave% <= testoctave% THEN top$ = "y" ELSE top$ = "n"
     IF top$ = "y" AND theoctave% = testoctave% THEN
      IF thepitch% <= testpitch% THEN top$ = "y" ELSE top$ = "n"
     ENDIF
     IF top$ = "y" AND theoctave% = testoctave% AND thepitch% = testpitch% THEN
      IF theaccid% <= testaccid% THEN top$ = "y" ELSE top$ = "n"
     ENDIF
    ENDIF
   IF bottom$ = "y" AND top$ = "y" THEN extract$ = "y"
 UNTIL extract$ = "y" OR attempts% = npitches%
  WHEN "random" :
   extract$ = "n"
   IF numb% = countt% THEN
    extract$ = "y"
    max% = higher%-lower%+1 : a% = RND(max%) : b% = lower% -1 : c% = countt%
    IF a% = 0 THEN a% = 1
    numb% = a% + b% + c%
    IF copymove$ = "EM" THEN numb% -= 1
   ENDIF
  WHEN "attackinterval" :
   bar1% = array%(startatcell%+countt%,0,voice%)DIV10^6
   beat1% = (array%(startatcell%+countt%,0,voice%)DIV10^3)MOD10^3
   beat1% = (bar1%*960)+beat1%
   bar2% = array%(startatcell%+countt%+1,0,voice%)DIV10^6
   beat2% = (array%(startatcell%+countt%+1,0,voice%)DIV10^3)MOD10^3
   beat2% = (bar2%*960)+beat2%
   interval% = beat2% - beat1%
   IF interval% >= lower% AND interval% <= higher% THEN extract$ = "y"
 ENDCASE
 :
 IF extract$ = "y" THEN
 counter% += 1
  attacks2%(counter%) = (array%(startatcell%+countt%,0,voice%))DIV10^3
  pitches%(counter%) = array%(startatcell%+countt%,0,voice%)MOD10^3
  durations%(counter%) = (array%(startatcell%+countt%,1,voice%)DIV10)MOD10^3
  amplitudes%(counter%) = (array%(startatcell%+countt%,1,voice%))MOD10
  envelopes%(counter%) = (array%(startatcell%+countt%,2,voice%))DIV10^2
  glissandos%(counter%) = (array%(startatcell%+countt%,1,voice%)DIV10^4)
  inflections%(counter%) = array%(startatcell%+countt%,2,voice%)MOD10^2
 IF copymove$ = "EM" THEN
 REM routine to delete each note as it is extracted, if move-extract wanted
  numnotes% = 1
  bar% = array%(startatcell%+countt%,0,voice%) DIV10^6
  beats% = (array%(startatcell%+countt%,0,voice%)DIV10^3)MOD10^3
  PROCalterbeats
  start% = (bar%*(10^3))+beats%
  PROCsearch(start%)
  PROCshuntleft(startcell%,numnotes%)
  countt% -= 1 : endcell% -= 1
  REM prev line is because of deletion, ie array cells have all now shifted one to left!
 ENDIF
 REM end of delete routine
 :
 ENDIF
 UNTIL countt% = endcell% - 1
 manyattacks% = counter%+1
 attacks1%(0) = (((attacks2%(0)DIV10^3)*960)+(attacks2%(0)MOD10^3)-960)-((copystartbar%*960)+copystartbeat%-960)
 FOR count% = 1 TO manyattacks% - 1
  bars% = (attacks2%(count%)DIV10^3)-(attacks2%(count%-1)DIV10^3)
  beats% = (attacks2%(count%)MOD10^3)-(attacks2%(count%-1)MOD10^3)
  attacks1%(count%) = attacks1%(count%-1) + (bars%*960) + beats%
 NEXT
 :
 :
 ENDPROC
 :
 REM********************************************************
 :
 DEF PROCextractinfo
 :
 IF quickextract$ = "n" THEN
 :
 CLS
 aslasttime$ = "n"
 PRINT'" Extract by pitches, pitch-band,"
 PRINT'" attack interval, random number"
 PRINT'" or as last time (P/B/A/R/L) "
 CASE GET$ OF
  WHEN "P","p","0" :
  CLS
  extractmode$ = "pitchclass"
  WHEN "B","b" :
  CLS : extractmode$ = "band"
  WHEN "R","r" :
  CLS : extractmode$ = "random"
  PRINT'" Random extractions follow "
  PRINT'" each other at a distance "
  INPUT '" of between how many notes "lower%
  INPUT '" and how many notes "higher%
  WHEN "A","a" :
   CLS : extractmode$ = "attackinterval"
  PRINT'" Extract notes which precede"
  PRINT'" next note by between"
  INPUT'" how many beats "lower%
  INPUT'" and how many beats "higher%
  WHEN "L","l" :
   aslasttime$ = "y"
  OTHERWISE CLS : extractmode$ = "pitchclass"
 ENDCASE
 :
 ENDIF
 :
 IF aslasttime$ = "n" THEN
 :
 IF extractmode$ = "pitchclass" OR extractmode$ = "band" THEN
 :
 IF quickextract$ = "n" THEN
  IF extractmode$ = "pitchclass" THEN
   INPUT'" How many pitch-classes? "npitches%
   IF npitches% = 0 THEN npitches% = 1
  ELSE
   INPUT'" How many bands "nbands%
   IF nbands% = 0 THEN nbands% = 1
  ENDIF
 ENDIF
 :
  IF extractmode$ = "band" THEN npitches% = nbands%*2
  FOR p% = 1 TO npitches%
  IF extractmode$ = "pitchclass" THEN
   PRINT' " Pitch-class ";p%;" has the note name ";
   ELSE PRINT'" Going up, band-point ";p%;" is note ";
  ENDIF
  COLOUR 3
  CASE GET$ OF
   WHEN "C","c" : note% = 0 : PRINT "C" : finished$ = "n"
   WHEN "D","d" : note% = 1 : PRINT "D" : finished$ = "n"
   WHEN "E","e" : note% = 2 : PRINT "E" : finished$ = "n"
   WHEN "F","f" : note% = 3 : PRINT "F" : finished$ = "n"
   WHEN "G","g" : note% = 4 : PRINT "G" : finished$ = "n"
   WHEN "A","a" : note% = 5 : PRINT "A" : finished$ = "n"
   WHEN "B","b" : note% = 6 : PRINT "B" : finished$ = "n"
   WHEN "1"     : note% = 0 : accid% = 5 : octave% = 4 : finished$ = "y"
   WHEN "2"     : note% = 0 : accid% = 9 : octave% = 4 : finished$ = "y"
   WHEN "3"     : note% = 1 : accid% = 5 : octave% = 4 : finished$ = "y"
   WHEN "4"     : note% = 2 : accid% = 1 : octave% = 4 : finished$ = "y"
   WHEN "5"     : note% = 2 : accid% = 5 : octave% = 4 : finished$ = "y"
   WHEN "6"     : note% = 3 : accid% = 5 : octave% = 4 : finished$ = "y"
   WHEN "7"     : note% = 3 : accid% = 9 : octave% = 4 : finished$ = "y"
   WHEN "8"     : note% = 4 : accid% = 5 : octave% = 4 : finished$ = "y"
   WHEN "9"     : note% = 5 : accid% = 1 : octave% = 4 : finished$ = "y"
  ENDCASE
  COLOUR 0
  :
  IF finished$ = "n" THEN
  :
  PRINT "               accidental ";
  COLOUR 3
  CASE GET$ OF
   WHEN "1" : accid% = 1 : PRINT "flat"
   WHEN "2" : accid% = 2 : PRINT "3/8flat"
   WHEN "3" : accid% = 3 : PRINT "1/4flat"
   WHEN "4" : accid% = 4 : PRINT "1/8flat"
   WHEN "5" : accid% = 5 : PRINT "nat"
   WHEN "6" : accid% = 6 : PRINT "1/8shrp"
   WHEN "7" : accid% = 7 : PRINT "1/4shrp"
   WHEN "8" : accid% = 8 : PRINT "3/8shrp"
   WHEN "9" : accid% = 9 : PRINT "shrp"
  ENDCASE
  COLOUR 0
  PRINT "                   octave ";
  COLOUR 3
  CASE GET$ OF
   WHEN "0" : octave% = 0 : PRINT "0"
   WHEN "1" : octave% = 1 : PRINT "1"
   WHEN "2" : octave% = 2 : PRINT "2"
   WHEN "3" : octave% = 3 : PRINT "3"
   WHEN "4" : octave% = 4 : PRINT "4"
   WHEN "5" : octave% = 5 : PRINT "5"
   WHEN "6" : octave% = 6 : PRINT "6"
   WHEN "7" : octave% = 7 : PRINT "7"
   WHEN "8" : octave% = 8 : PRINT "8"
  ENDCASE
  COLOUR 0
  :
  ENDIF
  :
  extractinfo%(p%) = (note%*100)+(accid%*10)+octave%
  NEXT
  :
 ENDIF
 :
 ENDIF
 :
 IF extractmode$ = "random" AND quickextract$ = "y" THEN
  PRINT '" Random extractions follow "
  PRINT ' " each other at a distance "
  INPUT  '" of between how many notes "lower%
  INPUT '" and how many notes "higher%
 ENDIF


 ENDPROC
 :
 REM*************************************************
 :
 DEF PROCequalizedurats
 :
 CLS
 PRINT'" There are ";manyattacks%-1;" durations "
 PRINT'" How many do you want to equalise? "
 PRINT " (0 = ";manyattacks%-1;")"
 INPUTnumdurats%
 IF numdurats% = 0 THEN numdurats% = manyattacks%-1
 INPUT'" Starting at duration number "startattack%
 IF startattack% = 0 THEN startattack% = 1
 IF (manyattacks%-startattack%)<numdurats% THEN startattack% = manyattacks%-numdurats%
 totaldurats% = 0
 FOR count% = startattack% TO (startattack%+numdurats%-1)
  totaldurats%+=(attacks1%(count%)-attacks1%(count%-1))
 NEXT
 average = totaldurats%/numdurats%


 residue% = average * 10
 residue% = residue%MOD10
 IF residue%>=5 THEN average% = ((average)DIV1)+1 ELSE average% = (average)DIV1
 FOR count% = startattack% TO (startattack%+numdurats%-1)
  attacks1%(count%) = attacks1%(count%-1)+average%
 NEXT
 adjust% = totaldurats% - (average%*numdurats%)
 attacks1%(count%-1) += adjust%
 equalized$ = "y" : seeequalizey$ = "n"
 PROCinsertattacks
 ENDPROC
 :
 REM************************************************
 :
 DEF PROCsavevoice
 :
 *Dir SDFS::RISCOSpi.$.CAC.Files
 INPUT'" filename "filenamevoice$
 channel = OPENOUT filenamevoice$
 PRINT#channel, manyattacks%
 FOR a% = 0 TO manyattacks%-1
  PRINT#channel, attacks1%(a%)
 NEXT
 FOR a% = 0 TO manyattacks%-1
  PRINT#channel, pitches%(a%)
 NEXT
 FOR a% = 0 TO manyattacks%-1
  PRINT#channel, durations%(a%)
 NEXT
 FOR a% = 0 TO manyattacks%-1
  PRINT#channel, amplitudes%(a%)
 NEXT
 FOR a% = 0 TO manyattacks%-1
  PRINT#channel, envelopes%(a%)
 NEXT
 FOR a% = 0 TO manyattacks%-1
  PRINT#channel, glissandos%(a%)
 NEXT
 FOR a% = 0 TO manyattacks%-1
  PRINT#channel, inflections%(a%)
 NEXT
 CLOSE#channel
 *NoDir
 savevoice$ = "N" : PROCdisplay
 ENDPROC
 :
 REM**********************************
 :
 DEF PROCimportvoice
 :
  *Dir SDFS::RISCOSpi.$.CAC.Files
 INPUT'" filename "filenamevoice$
 channel = OPENIN filenamevoice$
 REPEAT
  INPUT#channel, manyattacks%
  FOR a% = 0 TO manyattacks%-1
   INPUT#channel, attacks1%(a%)
  NEXT
  FOR a% = 0 TO manyattacks%-1
   INPUT#channel, pitches%(a%)
  NEXT
  FOR a% = 0 TO manyattacks%-1
   INPUT#channel, durations%(a%)
  NEXT
  FOR a% = 0 TO manyattacks%-1
   INPUT#channel, amplitudes%(a%)
  NEXT
  FOR a% = 0 TO manyattacks%-1
   INPUT#channel, envelopes%(a%)
  NEXT
  FOR a% = 0 TO manyattacks%-1
   INPUT#channel, glissandos%(a%)
  NEXT
FOR a% = 0 TO manyattacks%-1
   INPUT#channel, inflections%(a%)
  NEXT
 UNTIL EOF#channel
 CLOSE#channel
 *NoDir
 method$ = "raw" : copyit$ = "ON" : PROCinsertattacks
 ENDPROC
:
REM***********************************
:
DEF PROCpreintervalstring
:
PROCwindow(20,69,80,22)
PRINT'" Re-run current interval string,"
PRINT" create a new string, edit the"
 PRINT " current one, or load a file (R/N/E/F)"
 CASE GET$ OF
  WHEN "R","r" : PROCintervalstring
  WHEN "E","e" : loadstring$ = "n" :PROCeditintervalstring
  WHEN "F","f" : loadstring$ = "y" :PROCeditintervalstring
  OTHERWISE
 ENDCASE
 :
 filenamestg$ = ""
 numbannedpitches% = 0 : numbannedints% = 0 : bannedpitches%() = 0
:
INPUT'" How many pitches "numpitches%
INPUT'" The tessitura is how many semitones wide "tess%
PRINT'" The bottom pitch of the tessitura is ";
COLOUR 3
CASE GET$ OF
 WHEN "C","c" : note% = 1 : PRINT "C" : pitch$ = "C"
 WHEN "D","d" : note% = 3 : PRINT "D" : pitch$ = "D"
 WHEN "E","e" : note% = 5 : PRINT "E" : pitch$ = "E"
 WHEN "F","f" : note% = 6 : PRINT "F" : pitch$ = "F"
 WHEN "G","g" : note% = 8 : PRINT "G"  : pitch$ = "G"
 WHEN "A","a" : note% = 10 : PRINT "A" : pitch$ = "A"
 WHEN "B","b" : note% = 12 : PRINT "B"  : pitch$ = "B"
ENDCASE
COLOUR 0
PRINT " Accidental ";
COLOUR 3
CASE GET$ OF
 WHEN "1" : note% -= 1 : PRINT "flat" : accid$ = "flat"
 WHEN "5" : PRINT "nat" : accid$ = "nat"
 WHEN "9" : note% += 1 : PRINT "shrp"  : accid$ = "shrp"
OTHERWISE VDU 7
ENDCASE
COLOUR 0
PRINT " Octave ";
COLOUR 3
octave% = EVAL(GET$) : saveoctave% = octave%
PRINT octave%
COLOUR 0
transposer% = note% + (12*(octave%-1)) - 1
PRINT'" Are any pitches to be banned? "
 CASE GET$ OF
  WHEN "Y","y" :
   REPEAT
    numbannedpitches% += 1
    PRINT '" Pitch ";numbannedpitches%;" is, going up,"
    PRINT " semitone number what, starting at 0?"
    INPUT " (type F to finish) "bannedpitch$
    IF bannedpitch$ <> "F" AND bannedpitch$ <> "f" THEN bannedpitches%(numbannedpitches%) = EVAL(bannedpitch$) + 1
   UNTIL bannedpitch$ = "F" OR bannedpitch$ = "f"
  numbannedpitches% -= 1
  OTHERWISE
 ENDCASE
:
PRINT'" Are any intervals to be banned?"
 CASE GET$ OF
  WHEN "Y","y" :
   REPEAT
    numbannedints% += 1
    PRINT''" Interval ";numbannedints%;" is how many semitones?"
    PRINT" (NB intervals between 12 & 23 are "
    PRINT"  applied at all compounds - "
    INPUT"  type F to finish) "int$
    IF int$ <> "F" AND int$ <> "f" THEN
     PRINT'" And is banned at between a"
     INPUT" minimum of how many notes from the last one "range%
     INPUT" And a maximum of how many "range1%
     bannedints%(numbannedints%,0) = EVAL(int$)
     bannedints%(numbannedints%,1) = range%
     bannedints%(numbannedints%,2) = range1%
    ENDIF
   UNTIL int$ = "F" OR int$ = "f"
  numbannedints% -= 1
  OTHERWISE
 ENDCASE
:
stringattempts% = 0 : PROCintervalstring
:
ENDPROC
:
REM********************************************************
:
DEF PROCintervalstring
:
notenumber% = 0 : stringattempts% += 1
:
REPEAT
 notenumber% += 1 : triednotes%() = 0
 :
 REPEAT
  note% = RND(tess%+1) : triednotes%(note%) = 1
  count% = 0
  test$ = "pass"
  IF numbannedpitches% > 0 THEN
   REPEAT
    count% += 1
    IF note% = bannedpitches%(count%) THEN test$ = "fail"
   UNTIL test$ = "fail" OR count% = numbannedpitches%
  ENDIF
:
  IF notenumber% > 1 AND numbannedints% > 0 AND test$ = "pass" THEN
   count% = 0
   REPEAT
    count% += 1 : count1% = 0
    REPEAT
     count1% += 1
     testnotenumber% = bannedints%(count%,1)+count1%-1
     testnotenumber% = notenumber%-testnotenumber%
     IF testnotenumber% > 0 THEN
      IF note% >= amplitudes%(testnotenumber%) THEN
       interval% = note%-amplitudes%(testnotenumber%)
      ELSE interval% = amplitudes%(testnotenumber%)-note%
      ENDIF
      :
      REPEAT
       IF interval% > 23 THEN interval% -= 12
      UNTIL interval% < 24
      IF interval% = bannedints%(count%,0) THEN test$ = "fail"
      :
     ENDIF
    UNTIL count1% > (bannedints%(count%,2)-bannedints%(count%,1)) OR test$ = "fail"
   UNTIL count% = numbannedints% OR test$ = "fail"
  ENDIF
:
 REM check to see if all notes tried
 check$ = "alltried"
 FOR checker% = 1 TO tess%+1
  IF triednotes%(checker%) = 0 THEN check$ = "notalltried"
 NEXT
 UNTIL test$ = "pass" OR check$ = "alltried"
:
 amplitudes%(notenumber%) = note%
:
IF check$ = "alltried" AND test$ = "fail" THEN whattodo$ = "abort" ELSE whattodo$ = "continue"
UNTIL notenumber% = numpitches% OR whattodo$ = "abort"
:
IF whattodo$ = "abort" THEN
 CLS : PRINT''" Attempts from fresh start - ";stringattempts%
 PROCintervalstring
ELSE
 FOR count% = 1 TO numpitches%
  amplitudes%(count%) += transposer%
  REM which octave
  count1% = 0
  REPEAT
   count1% += 1
  UNTIL (count1%*12) >= amplitudes%(count%)
  octave% = count1%
  REM which pitch and accid
  amplitudes%(count%) -= (12*(octave%-1))
  CASE amplitudes%(count%) OF
   WHEN 1 : pitches%(count%-1) = 50 + octave%
   WHEN 2 : pitches%(count%-1) = 90 + octave%
   WHEN 3 : pitches%(count%-1) = 150 + octave%
   WHEN 4 : pitches%(count%-1) = 210 + octave%
   WHEN 5 : pitches%(count%-1) = 250 + octave%
   WHEN 6 : pitches%(count%-1) = 350 + octave%
   WHEN 7 : pitches%(count%-1) = 390 + octave%
   WHEN 8 : pitches%(count%-1) = 450 + octave%
   WHEN 9 : pitches%(count%-1) = 490 + octave%
   WHEN 10 : pitches%(count%-1) = 550 + octave%
   WHEN 11 : pitches%(count%-1) = 610 + octave%
   WHEN 12 : pitches%(count%-1) = 650 + octave%
  ENDCASE
 NEXT
 PRINT'" Do you want to save this interval string?"
 CASE GET$ OF
  WHEN "Y","y" : PROCsaveintervalstring
  OTHERWISE
 ENDCASE
 PROCinsertpitches
ENDIF
:
ENDPROC
:
REM**********************************************
:
DEF PROCsaveintervalstring
:
*Dir SDFS::RISCOSpi.$.CAC.Files
 firstnaming$ = "n"
 CLS
 IF filenamestg$ = "" THEN
 INPUT'" filename "filenamestg$
 firstnaming$ = "y"
 ENDIF
 IF firstnaming$ = "n" THEN
 PRINT'" as '";filenamestg$;"'?"
 CASE GET$ OF
  WHEN "N","n" : INPUT'" filename "filenamestg$
  OTHERWISE
 ENDCASE
 ENDIF
 :
 channel = OPENOUT filenamestg$
 PRINT#channel, numpitches%
 PRINT#channel, tess%
 PRINT#channel, numbannedpitches%
 PRINT#channel, numbannedints%
 PRINT#channel, transposer%
 PRINT#channel, pitch$
 PRINT#channel, accid$
 PRINT#channel, saveoctave%
 FOR a% = 1 TO numbannedpitches%
  PRINT#channel, bannedpitches%(a%)
 NEXT
 FOR a% = 1 TO numbannedints%
  FOR b% = 0 TO 2
   PRINT#channel, bannedints%(a%,b%)
  NEXT
 NEXT
 :
 CLOSE#channel
 *NoDir
 :
 ENDPROC
:
REM******************************************
:
DEF PROCloadintervalstring
:
 *Dir SDFS::RISCOSpi.$.CAC.Files
 INPUT'" filename "filenamestg$
 channel = OPENIN filenamestg$
 REPEAT
  INPUT#channel, numpitches%
  INPUT#channel, tess%
  INPUT#channel, numbannedpitches%
  INPUT#channel, numbannedints%
  INPUT#channel, transposer%
  INPUT#channel, pitch$
  INPUT#channel, accid$
  INPUT#channel, saveoctave%
  FOR a% = 1 TO numbannedpitches%
   INPUT#channel, bannedpitches%(a%)
  NEXT
  FOR a% = 1 TO numbannedints%
   FOR b% = 0 TO 2
      INPUT#channel, bannedints%(a%,b%)
   NEXT
  NEXT
UNTIL EOF#channel
 CLOSE#channel
 *NoDir
 :
 ENDPROC
:
REM**************************************
:
DEF PROCeditintervalstring
:
IF loadstring$ = "y" THEN PROCloadintervalstring
:
CLS
PRINT'" Alter the number of pitches?"
PRINT" (currently ";numpitches%;")"
CASE GET$ OF
 WHEN "Y","y" :
  INPUT'" How many pitches "numpitches%
ENDCASE
CLS
PRINT'" Alter tessitura and/or location?"
PRINT" (currently ";tess%;" semitones wide"
PRINT"  with a bottom note of ";pitch$;accid$;saveoctave%;")"
CASE GET$ OF
 WHEN "Y","y" :
  INPUT'" The tessitura is how many semitones wide "tess%
  PRINT'" The bottom pitch of the tessitura is ";
  COLOUR 3
  CASE GET$ OF
  WHEN "C","c" : note% = 1 : PRINT "C" : pitch$ = "C"
  WHEN "D","d" : note% = 3 : PRINT "D" : pitch$ = "D"
  WHEN "E","e" : note% = 5 : PRINT "E" : pitch$ = "E"
  WHEN "F","f" : note% = 6 : PRINT "F" : pitch$ = "F"
  WHEN "G","g" : note% = 8 : PRINT "G"  : pitch$ = "G"
  WHEN "A","a" : note% = 10 : PRINT "A"  : pitch$ = "A"
  WHEN "B","b" : note% = 12 : PRINT "B"  : pitch$ = "B"
 ENDCASE
 COLOUR 0
 PRINT " Accidental ";
 COLOUR 3
 CASE GET$ OF
  WHEN "1" : note% -= 1 : PRINT "flat" : accid$ = "flat"
  WHEN "5" : PRINT "nat" : accid$ = "nat"
  WHEN "9" : note% += 1 : PRINT "shrp" : accid$ = "shrp"
 OTHERWISE VDU 7
 ENDCASE
 COLOUR 0
 PRINT " Octave ";
 COLOUR 3
 octave% = EVAL(GET$) : saveoctave% = octave%
 PRINT octave%
 COLOUR 0
 transposer% = note% + (12*(octave%-1)) - 1
OTHERWISE
ENDCASE
:
PRINT'" Alter the banning of pitches? "
IF numbannedpitches% = 0 THEN
PRINT" No pitches are currently banned "
ELSE
PRINT"  Currently banned pitches are,"
PRINT"  going up, starting at 0 -"
PRINT" "
VDU 14
FOR count% = 1 TO numbannedpitches%
 PRINT " ";count%;".   semitone ";bannedpitches%(count%)-1
NEXT
VDU 15
ENDIF
 CASE GET$ OF
  WHEN "Y","y" :
   INPUT'" The number of banned pitches is now to be "numbannedpitches%
    FOR count% = 1 TO numbannedpitches%
    PRINT'" Alter banned pitch ";count%
    CASE GET$ OF
     WHEN "Y","y" :
    PRINT '" Pitch ";count%;" is, going up,"
    INPUT " semitone number what, starting at 0?"semitone%
    bannedpitches%(count%) = semitone%+1
    ENDCASE
   NEXT
 ENDCASE
 CLS : VDU 14
PRINT'" Alter the banning of intervals?"
IF numbannedints% = 0 THEN
PRINT" No intervals are currently banned "
ELSE
VDU 28,20,43,70,15
PRINT" Currently banned intervals are -"
PRINT" "
FOR count% = 1 TO numbannedints%
IF bannedints%(count%,1) > 0 THEN COLOUR 131 ELSE COLOUR 191
 IF count% > 9 AND bannedints%(count%,0) > 9 THEN PRINT " ";count%;". ";bannedints%(count%,0);" semitones at between ";bannedints%(count%,1);" and ";bannedints%(count%,2);" notes"
 IF count% < 10 EOR bannedints%(count%,0) < 10 THEN PRINT " ";count%;".  ";bannedints%(count%,0);" semitones at between ";bannedints%(count%,1);" and ";bannedints%(count%,2);" notes"
 IF count% < 10 AND bannedints%(count%,0) < 10 THEN PRINT " ";count%;".   ";bannedints%(count%,0);" semitones at between ";bannedints%(count%,1);" and ";bannedints%(count%,2);" notes"
NEXT
COLOUR 191
VDU 15
ENDIF
 CASE GET$ OF
  WHEN "Y","y" :
   VDU 28,20,65,70,45
   PRINT'" Alter the number of banned intervals?"
   CASE GET$ OF
    WHEN "Y","y" :
     INPUT'" The number of banned intervals is now to be "numbannedints%
   ENDCASE
   FOR count% = 1 TO numbannedints%
    PRINT'" Alter interval ";count%
    CASE GET$ OF
     WHEN "Y","y" :
      PRINT'" Interval ";count%;" is how many semitones?"
      PRINT" (NB intervals between 12 & 23 are "
      INPUT"  applied at all compounds) "bannedints%(count%,0)
      PRINT'" And is banned at between a minimum"
      INPUT" of how many notes from the last one "range%
      INPUT" And a maximum of how many "range1%
      bannedints%(count%,1) = range%
      bannedints%(count%,2) = range1%
     OTHERWISE
     ENDCASE
   NEXT
 ENDCASE
:
stringattempts% = 0 : PROCintervalstring
:
ENDPROC
:
REM********************************************************
:
DEF PROCconvertpitch
:
 CASE (pitch%DIV10^2) OF
  WHEN 0 : note% = 1
  WHEN 1 : note% = 3
  WHEN 2 : note% = 5
  WHEN 3 : note% = 6
  WHEN 4 : note% = 8
  WHEN 5 : note% = 10
  WHEN 6 : note% = 12
 ENDCASE
 :
 CASE ((pitch%DIV10)MOD10) OF
  WHEN 1 : note% -= 1
  WHEN 9 : note% += 1
  OTHERWISE
 ENDCASE
 :
 octave% = pitch%MOD10
 note% = note% + (12*(octave%-1))
 chunk% = 12 : compoundint% = compoundpitch%
ENDPROC
:
REM****************************************************
:
DEF PROCconvertquarter
:
 CASE (pitch%DIV10^2) OF
  WHEN 0 : note% = 2
  WHEN 1 : note% = 6
  WHEN 2 : note% = 10
  WHEN 3 : note% = 12
  WHEN 4 : note% = 16
  WHEN 5 : note% = 20
  WHEN 6 : note% = 24
 ENDCASE
 :
 CASE ((pitch%DIV10)MOD10) OF
  WHEN 1 : note% -= 2
  WHEN 3 : note% -= 1
  WHEN 7 : note% += 1
  WHEN 9 : note% += 2
  OTHERWISE
 ENDCASE
 :
 octave% = pitch%MOD10
 note% = note% + (24*(octave%-1))
 chunk% = 24 : compoundint% = compoundquarter%
ENDPROC
ENDPROC
:
REM****************************************************
:
DEF PROCconverteighth
:
 CASE (pitch%DIV10^2) OF
  WHEN 0 : note% = 4
  WHEN 1 : note% = 12
  WHEN 2 : note% = 20
  WHEN 3 : note% = 24
  WHEN 4 : note% = 32
  WHEN 5 : note% = 40
  WHEN 6 : note% = 48
 ENDCASE
 :
 CASE ((pitch%DIV10)MOD10) OF
  WHEN 1 : note% -= 4
  WHEN 2 : note% -= 3
  WHEN 3 : note% -= 2
  WHEN 4 : note% -= 1
  WHEN 6 : note% += 1
  WHEN 7 : note% += 2
  WHEN 8 : note% += 3
  WHEN 9 : note% += 4
  OTHERWISE
 ENDCASE
 :
 octave% = pitch%MOD10
 note% = note% + (48*(octave%-1))
 chunk% = 48 : compoundint% = compoundeighth%
ENDPROC
:
REM****************************************************
:
DEF PROCconvertcent
:
 CASE (pitch%DIV10^2) OF
  WHEN 0 : note% = 100
  WHEN 1 : note% = 300
  WHEN 2 : note% = 500
  WHEN 3 : note% = 600
  WHEN 4 : note% = 800
  WHEN 5 : note% = 1000
  WHEN 6 : note% = 1200
 ENDCASE
 :
 CASE ((pitch%DIV10)MOD10) OF
  WHEN 1 : note% -= 100
  WHEN 2 : note% -= 75
  WHEN 3 : note% -= 50
  WHEN 4 : note% -= 25
  WHEN 6 : note% += 25
  WHEN 7 : note% += 50
  WHEN 8 : note% += 75
  WHEN 9 : note% += 100
  OTHERWISE
 ENDCASE
 :
 octave% = pitch%MOD10
 note% = note% + (1200*(octave%-1)) + cent%
 chunk% = 1200 : compoundint% = compoundcent%
ENDPROC
:
REM****************************************************
:
DEF PROCrandomnumber
:
PROCwindow(20,65,65,55)
CLS
:
IF rerun$ = "n" THEN
INPUT'" Return a random number between ? "ranx%
INPUT " and ? "rany%
ENDIF
diff% = (rany%-ranx%)+1
PRINT' RND(diff%)+(ranx%-1)
:
PRINT '" (press R to re-run, U for new number "
PRINT  "  or any key to continue) "
CASE GET$ OF
 WHEN "U","u" : rerun$ = "n" : PROCrandomnumber
 WHEN "R","r" : rerun$ = "y" : PROCrandomnumber
 OTHERWISE PROCdisplay
ENDCASE
ENDPROC
:


REM****************************************************
:
DEF PROCcheckproportiontotal
:
proportiontotal$ = "notOK"
:
 it% = 0
REPEAT
 it% += 1
 mplier = 0.5
 REPEAT
  mplier = mplier*2
  testnum% = it%*mplier
posslownum = grouplength%/beatfactor%
WHILE posslownum > proportiontotal%
posslownum = posslownum/2
ENDWHILE
WHILE posslownum <= (proportiontotal%/2)
posslownum = posslownum*2
ENDWHILE
IF proportiontotal% = testnum% AND ((it%/testnum%)*posslownum*10^3)MOD10^3=0 THEN proportiontotal$ = "OK"
IF proportiontotal% = posslownum THEN proportiontotal$ = "OK"
 UNTIL proportiontotal$ = "OK" OR testnum% > (grouplength%/defaultmindur%)
UNTIL proportiontotal$ = "OK" OR it% = given%
:
IF proportiontotal%>9999 THEN proportiontotal$ = "notOK"
:
ENDPROC
:
REM***************************************************
:
DEF PROCredpitches
:
tiss% = 0
REPEAT
tiss%+=1
toss% = 0 : dored$ = "n"
REPEAT
toss%+=1
IF (array%(startcell%,0,voice%)MOD10^3) = redpitches%(tiss%,toss%) THEN
 IF printing$ = "n" THEN GCOL tiss%
 dored$ = "y"
ENDIF
UNTIL dored$ = "y" OR toss% = numredpitches%(tiss%)
UNTIL dored$ = "y" OR tiss% = numcols%
ENDPROC
:
REM****************************************************
:
DEF PROCpitchstring2
:
IF easiermenus$ = "n" THEN PROCwindow(20,65,60,55) ELSE PROCwindow(20,65,60,42)
PRINT'" This function returns a string"
PRINT" of pitches drawn from a semitonal"
PRINT" cluster based on middle C,"
PRINT" with a controlled chance "
PRINT" of pitch repetitions"
INPUT'" How many semitones in the cluster "numsemis%
INPUT'" How many pitches in the string "numpitches%
PRINT'" Randomly occuring pitch repetitions "
PRINT" are included or not by what "
INPUT" percentage? "percentage%
:
x% = RND(numsemis%)
CASE x% OF
 WHEN 1 : pitches%(0) = 54
 WHEN 2 : pitches%(0) = 94
 WHEN 3 : pitches%(0) = 154
 WHEN 4 : pitches%(0) = 214
 WHEN 5 : pitches%(0) = 254
 WHEN 6 : pitches%(0) = 354
 WHEN 7 : pitches%(0) = 394
 WHEN 8 : pitches%(0) = 454
WHEN 9 : pitches%(0) = 514
 WHEN 10 : pitches%(0) = 554
 WHEN 11 : pitches%(0) = 614
 WHEN 12 : pitches%(0) = 654
ENDCASE
:
FOR count% = 1 TO numpitches%-1
REPEAT
 continue$ = "y"
x% = RND(numsemis%)
CASE x% OF
 WHEN 1 : pitches%(count%) = 54
 WHEN 2 : pitches%(count%) = 94
 WHEN 3 : pitches%(count%) = 154
 WHEN 4 : pitches%(count%) = 214
 WHEN 5 : pitches%(count%) = 254
 WHEN 6 : pitches%(count%) = 354
 WHEN 7 : pitches%(count%) = 394
 WHEN 8 : pitches%(count%) = 454
WHEN 9 : pitches%(count%) = 514
 WHEN 10 : pitches%(count%) = 554
 WHEN 11 : pitches%(count%) = 614
 WHEN 12 : pitches%(count%) = 654
ENDCASE
:
IF pitches%(count%) = pitches%(count%-1) THEN
 y% = RND(100)
 IF y% <= percentage% THEN continue$ = "y" ELSE continue$ = "n"
ENDIF
UNTIL continue$ = "y"
NEXT
:
PROCinsertpitches
ENDPROC
:
REM***************************************
:
DEF PROCrhythmdefaults
shortirrat% = 240
  longirrat% = 240
  irratbeats% = 4
  irratbeats1% = 4
  mindur% = 60 : sieve = 960/mindur%
  buffer% = 960/(sieve*2)
  given% = 9
  defaultsieve = 2
ENDPROC
:
REM******************************************
:
DEF PROCdisplayoptions
:
PROCwindow(2,72,97,1)
OFF
PRINT' " Do you want to (press to toggle)"

IF copytoend$ = "y" THEN state$ = "on" ELSE state$ = "off"
IF seegraph$ = "y" THEN state1$ = "on" ELSE state1$ = "off"
PRINT' " See graph during accel/rit              G (";state1$;")          Allow copying to last note ^A (";state$;")"

IF seeinfo$ = "y" THEN state$ = "on" ELSE state$ = "off"
IF nodelay$ = "y" THEN state1$ = "on" ELSE state1$ = "off"
PRINT' " See info on attacks                     A (";state$;")          Pause for querying stave   ^D (";state1$;")"

IF printinfo$ = "y" THEN state$ = "on" ELSE state$ = "off"
IF askprevious$ = "y" THEN state1$ = "on" ELSE state1$ = "off"
PRINT' " get printout of info on attacks         I (";state$;")          Pause for previous position^F (";state1$;")"

IF seereorder$ = "y" THEN state$ = "on" ELSE state$ = "off"

IF errorbeforedisplay$ = "n" THEN state1$ = "off" ELSE state1$ = "on"

PRINT' " Re-order attacks                        R (";state$;")          Debugging mode             ^G (";state1$;")"

IF seereorderx$ = "y" THEN state$ = "on" ELSE state$ = "off"

PRINT' " Re-order attacks during accel/rit only ^R (";state$;")"

IF seeequalize$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Equalize attacks                        E (";state$;")          [press spacebar to continue] "
IF seeequalizex$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Equalize attacks during accel/rit only ^E (";state$;")"
IF seerhythmicize$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Rhythmicize attacks                     H (";state$;")"
IF reorderpitches$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Re-order pitches using M/A/P           ^P (";state$;")"
IF seequery$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Query before adding new values to array Q (";state$;")"
PRINT' " Define parameter values during input    P (";paraset$;")"
PRINT' " Accel/rit by total durat, endpoints or   "
PRINT  "  first two notes displayed          T/N/F (";funcinput$;")"
IF startfinishdurats$ = "Y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Accel/rit by start and finish durations S (";state$;")"
IF seeduration$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " See duration upto last displayed bar    D (";state$;")"
IF quickcopy$ = "y" THEN state$ ="on" ELSE state$ = "off"
PRINT' " Quick copy                              B (";state$;")"

CASE seedurinbts$ OF
 WHEN "y" : state$ = "on"
 WHEN "stepped" : state$ = "stepped"
 WHEN "n" : state$ = "off"
ENDCASE
PRINT' " See durations in micro-beats            K (";state$;")"

CASE seedurincrots$ OF
 WHEN "y" : state$ = "on"
 WHEN "stepped" : state$ = "stepped"
 WHEN "n" : state$ = "off"
ENDCASE
PRINT' " See durations in macro-beats            C (";state$;")"

IF screenvoices$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Voice numbers by 1/2/3 on screen        V (";state$;")"
IF ampoptions$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Use advanced amplitudes options         O (";state$;")"
PRINT' " Double v/^ moves down/up by 3/10 staves Z (";screenmovesby%;")"
CASE setalong$ OF
 WHEN "y" : state$ = "A/R"
 WHEN "n" : state$ = "quick"
 WHEN "playnovoices" : state$ = "play"
ENDCASE
PRINT' " 1,2 = A/R start/quickdisplay/play vces  J (";state$;")"
CASE envelopedata$ OF
 WHEN "none" : stage$ = "neither"
 WHEN "percentage" : stage$ = "%'s"
 WHEN "marker" : stage$ = "indicators"
ENDCASE
PRINT' " See envelope %'s/indicators/neither     L (";stage$;")"
IF askaboutpitches$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Query if pitches all the same           M (";state$;")"
IF usebottomstave$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Group of pitches fills bottom stave     U (";state$;")"
CASE sequalssection$ OF
 WHEN "y" : state$ = "sect"
 WHEN "n" : state$ = "next"
ENDCASE
PRINT' " Copy from next voices/Go to section    ^S (";state$;")"
IF addpitches$ = "y" THEN state$ = "pitch" ELSE state$ = "env"
PRINT' " ^Y = Add pitches/edit envelope          Y (";state$;")"
IF squarebracket$ = "remarks" THEN state$ = "remarks" ELSE state$ = "copy +"
PRINT' " [] keys = move remarks/add to copydown  [ (";state$;")"
IF queryalong$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Accel/rit asks for starting attack      ] (";state$;")"
PRINT' " Reset no.staves ^/v moves up/down by    ~"
IF singlepitch$ = "m" THEN state$ = "multiple" ELSE state$ = "single"
PRINT' " Y = single/multiple pitch entry         @ (";state$;")"
IF namestaves$ = "nameone" THEN state$ = "rename" ELSE state$ = "delete"
PRINT' " ^V = rename/delete batch of voice names^V (";state$;")"
IF usebeep$ = "n" THEN state$ = "assnd" ELSE state$ = "beep"
PRINT' " Play with beep or assigned voices      ^B (";state$;")"
IF onlycontent$ = "y" THEN state$ = "on" ELSE state$ = "off"
PRINT' " Display only voices with content       ^C (";state$;")"
PRINT' " Show list of voices with content       ^L"
 :
 CASE GET$ OF
 :
  WHEN "g" :
   IF seegraph$ = "y" THEN seegraph$ = "n" ELSE seegraph$ = "y"
  WHEN "a" :
   IF seeinfo$ = "y" THEN seeinfo$ = "n" ELSE seeinfo$ = "y"
  WHEN "A" :
   IF copytoend$ = "y" THEN copytoend$ = "n" ELSE copytoend$ = "y"
  WHEN "I","i" :
   IF printinfo$ = "y" THEN printinfo$ = "n" ELSE printinfo$ = "y"
  WHEN "r" :
   IF seereorder$ = "y" THEN
    seereorder$ = "n"
    seereordery$ = "n"
   ELSE
    seereorder$ = "y"
    seereorderx$ = "y"
    seereordery$ = "y"
   ENDIF
  WHEN "R" :
   IF seereorderx$ = "y" THEN
   seereorderx$ = "n"
   seereordery$ = "n"
   ELSE seereorderx$ = "y"
   ENDIF
  WHEN "e" :
  IF seeequalize$ = "y" THEN
    seeequalize$ = "n"
    seeequalizey$ = "n"
   ELSE
    seeequalize$ = "y"
    seeequalizex$ = "y"
    seeequalizey$ = "y"
   ENDIF
  WHEN "E" :
  IF seeequalizex$ = "y" THEN
   seeequalizex$ = "n"
   seeequalizey$ = "n"
   ELSE seereorderx$ = "y"
   ENDIF
  WHEN "P" :
   IF reorderpitches$ = "y" THEN reorderpitches$ = "n" ELSE reorderpitches$ = "y"
  WHEN "H","h" :
   IF seerhythmicize$ = "y" THEN seerhythmicize$ = "n" ELSE seerhythmicize$ = "y"
  WHEN "Q","q" :
   IF seequery$ = "y" THEN seequery$ = "n" ELSE seequery$ = "y"
  WHEN "p" :
   IF paraset$ = "on" THEN paraset$ = "off" ELSE paraset$ = "on"
  WHEN "T","t" :
    funcinput$ = "durat"
  WHEN "N","n" :
    funcinput$ = "points"
  WHEN "f" :
    funcinput$ = "displayed"
  WHEN "s" :
   IF startfinishdurats$ = "Y" THEN startfinishdurats$ = "N" ELSE startfinishdurats$ = "Y"
  WHEN "d" :
   IF seeduration$ = "y" THEN
    seeduration$ = "n" : PROCdisplay
   ELSE seeduration$ = "y" : PROCdisplay
   ENDIF
 WHEN "b" :
   IF quickcopy$ = "n" THEN quickcopy$ = "y" ELSE quickcopy$ = "n"
 WHEN "K","k" :
   IF seedurinbts$ = "n" THEN
    seedurinbts$ = "y" : seedurincrots$ = "n" : PROCdisplay
   ENDIF
   IF seedurinbts$ = "y" THEN
    seedurinbts$ = "stepped" : seedurincrots$ = "n" : PROCdisplay
  ENDIF
  IF seedurinbts$ = "stepped" THEN
   seedurinbts$ = "n": PROCdisplay
   ENDIF
 WHEN "c" :
   IF seedurincrots$ = "n" THEN
     seedurincrots$ = "y" : seedurinbts$ = "n" : PROCdisplay
   ENDIF
   IF seedurincrots$ = "y" THEN
     seedurincrots$ = "stepped" : seedurinbts$ = "n" : PROCdisplay
   ENDIF
   IF seedurincrots$ = "stepped" THEN
    seedurincrots$ = "n" : PROCdisplay
   ENDIF
 WHEN "v" :
   IF screenvoices$ = "n" THEN screenvoices$ = "y" ELSE screenvoices$ = "n" : PROCdisplay
 WHEN "V" :
  IF namestaves$ = "nameone" THEN namestaves$ = "deletemany" ELSE namestaves$ = "nameone"
 WHEN "O","o" :
   IF ampoptions$ = "n" THEN ampoptions$ = "y" ELSE ampoptions$ = "n" : PROCdisplay
 WHEN "z","Z" : IF screenmovesby% = 10 THEN screenmovesby% = 3 ELSE screenmovesby% = 10 : PROCdisplay
 WHEN "J","j" :
  CASE setalong$ OF
   WHEN "y" : setalong$ = "n"
   WHEN "n" : setalong$ = "playnovoices"
   WHEN "playnovoices" : setalong$ = "y"
  ENDCASE
 WHEN "l" :
  CASE envelopedata$ OF
   WHEN "none" : envelopedata$ = "percentage"
   WHEN "percentage" : envelopedata$ = "marker"
   WHEN "marker" : envelopedata$ = "none"
 ENDCASE
 WHEN "M","m" :
  IF askaboutpitches$ = "y" THEN askaboutpitches$ = "n" ELSE askaboutpitches$ = "y"
 WHEN "U","u" :
  IF usebottomstave$ = "y" THEN usebottomstave$ = "n" ELSE usebottomstave$ = "y"
  IF usebottomstave$ = "y" THEN askaboutpitches$ = "n" ELSE askaboutpitches$ = "y"
 WHEN "S" :
  CASE sequalssection$ OF
   WHEN "y" : sequalssection$ = "n"
   WHEN "n" : sequalssection$ = "y"
  ENDCASE
 WHEN "y","Y" :
  IF addpitches$ = "y" THEN addpitches$ = "n" ELSE addpitches$ = "y"
 WHEN "[" :
  IF squarebracket$ = "remarks" THEN squarebracket$ = "addten" ELSE squarebracket$ = "remarks"
 WHEN "]" :
  IF queryalong$ = "y" THEN queryalong$ = "n" ELSEqueryalong$ = "y"
 WHEN "~" :
  CLS
  INPUT " pressing ^ or v movesup/down by how many staves "updisplay%
 WHEN "@" :
  IF singlepitch$ = "s" THEN singlepitch$ = "m" ELSE singlepitch$ = "s"
 WHEN "B" :
  IF usebeep$ = "y" THEN usebeep$ = "n" ELSE usebeep$ = "y"
 WHEN "C" :
  IF onlycontent$ = "y" THEN onlycontent$ = "n" ELSE onlycontent$ = "y"
  PROCdisplayonlycontent
 WHEN "L" : PROCcontentonlylist
 WHEN "D" : IF nodelay$ = "y" THEN nodelay$ = "n" ELSE nodelay$ = "y"
 WHEN "F" : IF askprevious$ = "y" THEN askprevious$ = "n" ELSE askprevious$ = "y"
 WHEN "G" : IF errorbeforedisplay$ = "n" THEN errorbeforedisplay$ = "debug" ELSE errorbeforedisplay$ = "n"
:
OTHERWISE
:
ENDCASE
 ON
 :
 ENDPROC
 :
 REM******************************************************************
 :
 DEF PROCremarks
 :
 CLS
 INPUT'" Which bar "baar%
 PRINT'" line 1 or 2 "
 CASE GET$ OF
  WHEN "1" : line% = 0
  WHEN "2" : line% = 1
  OTHERWISE VDU7 : PROCremarks
 ENDCASE
 INPUT '" What are the remarks "remarks$
 remarks$(baar%,line%) = remarks$
 :
 ENDPROC
:
REM********************************************************************
:
DEF PROCwindow(a%,b%,c%,d%)
:
bigger$ = "n"
IF a% < biga% THEN
 biga% = a% : bigger$ = "y"
ENDIF
IF b% > bigb% THEN
 bigb% = b% : bigger$ = "y"
ENDIF
IF c% > bigc% THEN
 bigc% = c% : bigger$ = "y"
ENDIF
IF d% < bigd% THEN
 bigd% = d% : bigger$ = "y"
ENDIF
:
IF box$ = "n" THEN
 box$ = "y"
 VDU 28,a%-1,b%+1,c%+1,d%-1 : COLOUR 131 : CLS
 VDU 28,a%,b%,c%,d% : COLOUR 0 : COLOUR 191 : CLS : OFF
ELSE
 IF bigger$ = "y" THEN
  VDU 28,a%-1,b%+1,c%+1,d%-1 : COLOUR 131 : CLS
 ENDIF
 CLS : VDU 28,a%,b%,c%,d% : COLOUR 0 : COLOUR 191 : CLS : OFF
ENDIF
:
ENDPROC
:
REM***********************************************
:
DEF PROCslave
 REM this program returns not simply a random
 REM percentage (tends to be too high) nor
 REM a random percentage of a random percentage
 REM (tends to be too low), but something
 REM inbetween, averaging not 50% nor 25% but 37.5%
 :
IF quickslave$ = "n" THEN
IF easiermenus$ = "n" THEN PROCwindow(20,69,96,55) ELSE PROCwindow(20,69,96,42)
PRINT''" To begin, display the Mastervoice's two half-phases first on the screen."
PRINT  " This function then generates a Slavevoice's associated two half-phases,"
PRINT  " their random starting and ending points averaging 37.5% and 62.5% of the"
PRINT  " MV half-phases respectively (other averages tend to be too high or too low)"
PRINT '" Alternatively, percentages may be determined - "
PRINT  " press D for determined or R for random now "
CASE GET$ OF
 WHEN "D","d" : slavemethod$ = "determined"
 OTHERWISE slavemethod$ = "random"
ENDCASE
ENDIF
:
 test$ = "n"
PROCinput
:
ENDPROC
:
DEF PROCinput
REM procedure for getting first 2 attacks displayed
IF quickslave$ = "y" THEN
 IF easiermenus$ = "n" THEN PROCwindow(20,67,49,55) ELSE PROCwindow(20,67,49,42)
ENDIF
  INPUT '" Mastervoice is which voice "voice%
  IF voice% = 0 THEN voice% = savevoice%
  IF voice% <> 0 THEN savevoice% = voice%
  voice% -= 1
  startingbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  startbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  midbar% = array%(holdstartcell%(voice%)+1+along%,0,voice%)DIV10^6
  midbeat% = (array%(holdstartcell%(voice%)+1+along%,0,voice%)MOD10^6)DIV10^3
  endbar% = array%(holdstartcell%(voice%)+2+along%,0,voice%)DIV10^6
  endbeat% = (array%(holdstartcell%(voice%)+2+along%,0,voice%)MOD10^6)DIV10^3
 startpoint% = startingbar%*960
 startpoint% += startbeat%
 midpoint% = midbar%*960
 midpoint% += midbeat%
 endpoint% = endbar% * 960
 endpoint% += endbeat%
PROCprogram
ENDPROC
:
DEF PROCprogram
 IF test$ = "y" THEN number% = 1000 ELSE number% = 1
 total% = 0 : total1% = 0
 FOR count% = 1 TO number%
 firstdur% = midpoint%-startpoint%
 seconddur% = endpoint%-midpoint%
 REPEAT
 IF slavemethod$ = "determined" THEN
 INPUT'" Percentage for first half-phase is..."percentage%
 ELSE
  c% = RND(100)
 percentage% = RND(100) * (RND(101-c%)+(c%-1)) / 100
 ENDIF
 UNTIL percentage% >= lowerstart% AND percentage% <= upperstart%
 SVfirstdur% = firstdur%*percentage%/100
 REPEAT
 IF slavemethod$ = "determined" THEN
 INPUT'" Percentage for second half-phase is..."percentage1%
 ELSE
  c% = RND(100)
 percentage1% = 100 - (RND(100) * (RND(101-c%)+(c%-1)) / 100)
 ENDIF
 UNTIL percentage1% >= lowerend% AND percentage1% <= upperend%
 SVseconddur% = seconddur%*percentage1%/100
:
 SVtotaldur% = firstdur% - SVfirstdur% + SVseconddur%
 SVthirddur% = SVtotaldur%/(firstdur%+seconddur%)*firstdur%
:
 SVbar% = startingbar%
 SVbeat% = startbeat% + SVfirstdur%
 PROCbeats
 SVstartbar% = SVbar% : SVstartbeat% = SVbeat%
:
 SVbar% = SVstartbar%
 SVbeat% = SVstartbeat% + SVthirddur%
 PROCbeats
 SVmidbar% = SVbar% : SVmidbeat% = SVbeat%
:
 SVbar% = midbar%
 SVbeat% = midbeat% + SVseconddur%
 PROCbeats
 SVendbar% = SVbar% : SVendbeat% = SVbeat%
:
IF quickslave$ = "y" THEN
 IF easiermenus$ = "n" THEN PROCwindow(20,69,82,55) ELSE PROCwindow(20,69,82,42)
ENDIF
CLS
PRINT'" The Slavevoice's first half-phase starts at ";SVstartbar%;".";SVstartbeat%;" (";percentage%;"%)"
 PRINT  '"                                 and ends at ";SVmidbar%;".";SVmidbeat%
 PRINT  '"           And its second half-phase ends at ";SVendbar%;".";SVendbeat%;" (";percentage1%;"%)"
 total% += percentage% : total1% += percentage1%
 NEXT
 IF test$ = "y" THEN
 PRINT''" Average 1st percent = ";total%/1000
 PRINT" Average second = ";total1%/1000
 PRINT'" to continue press C"
 CASE GET$ OF
  WHEN"C","c" : PROCdisplay
 ENDCASE
 ENDIF
PRINT''" Do you want to add this slave voice to the array?"
PRINT" (or, to test average percentages out of 1000 throws, press P"
PRINT"  or, to set limits for the random percentages, press L)"
 CASE GET$ OF
 WHEN"Y","y" :
 WHEN"N","n" : PROCdisplay
 WHEN "P","p" : test$ = "y" : PROCprogram
 WHEN "L","l" : PROClimits
 ENDCASE
attacks1%(1) = ((SVmidbar%*960)+SVmidbeat%) -  ((SVstartbar%*960)+SVstartbeat%)
attacks1%(2) = ((SVendbar%*960)+SVendbeat%) -  ((SVstartbar%*960)+SVstartbeat%)
funcbar% = SVstartbar% : funcbeat% = SVstartbeat%
method$ = "raw" : quiz$ = "no" : manyattacks% = 3
PROCinsertattacks
ENDPROC
:
DEF PROCbeats
 WHILE SVbeat% > 959
  SVbeat% -= 960 : SVbar% += 1
 ENDWHILE
 ENDPROC
:
DEF PROClimits
 INPUT'" Give the lower limit for SV's start-point, between 1% & 99% "lowerstart%
 INPUT " Give the upper limit for SV's start-point, between 1% & 99% "upperstart%
INPUT'" Give the lower limit for SV's end-point, between 1% & 99% "lowerend%
PRINT " Give the upper limit for SV's end-point, between 1% & 99% "
INPUT " (these limits last for the session) "upperend%
PROCdisplay
ENDPROC
:
ENDPROC
:
REM*******************************************
:
DEF PROCprintattacks
:
 durat% = 0
 MODE 16 : COLOUR 0 : COLOUR 191 : CLS
 PRINT '" The group of attacks will be at "
 PRINT"  "
 PRINT TAB(8) "ATTACKS AT";
 PRINT TAB(30) "DURATIONS";
 PRINT TAB(54) "RATIOS"
 tal% = 0 : printnum% = 0
 FOR count% = 0 TO (manyattacks%-1)
 tal% += 1
  PRINT TAB(1)(attacks2%(count%))DIV10^3;" ";
  PRINT ;(attacks2%(count%))MOD10^3;
 IF count% > 0 THEN
  durat1% = durat%
  durat% = (attacks2%(count%)MOD10^3)-(attacks2%(count%-1)MOD10^3)
 addon% = ((attacks2%(count%)DIV(10^3))-(attacks2%(count%-1)DIV(10^3)))*960
 durat% = durat% + addon%
  PRINT TAB(26) durat%;
  IF count%>1 THEN
 IF direction$ = "rit" THEN ratio = durat%/durat1% ELSE ratio = durat1%/durat%
 CASE ratio OF
  WHEN 0.5 : PRINT TAB(52) "0.5"
  WHEN 1.0 : PRINT TAB(52) "1.0"
  WHEN 1.5 : PRINT TAB(52) "1.5"
  WHEN 2.0 : PRINT TAB(52) "2.0"
  WHEN 2.5 : PRINT TAB(52) "2.5"
  OTHERWISE PRINT TAB(52) ratio
 ENDCASE
  ENDIF
 ENDIF
 IF tal% > 54 AND printinfo$ = "y" THEN
 printnum% += 1
 MOVE 0,0
 MOVE 1800,1223
 *SGet mysprite
 OSCLI "SSave SDFS::RISCOSpi.$.CAC.Printing."+STR$(printnum%)
 tal% = 0
 ENDIF
 NEXT
 IF printinfo$ = "y" THEN
 MOVE 0,0
 MOVE 1800,1223
 *SGet mysprite
 OSCLI "SSave SDFS::RISCOSpi.$.CAC.Printing."+STR$(printnum%+1)
 ENDIF
 :
 PROCdisplay
:
ENDPROC
:
REM*************************************************
:
DEF PROCnamestaves
 :
CLS
INPUT'" Rename which voice "thevoice%
INPUT' " calling it what "thename$
insts$(thevoice%,0) = thename$
:
ENDPROC
:
REM**************************************************
:
DEF PROCdeletenames
:
INPUT'" Delete names between voice "firstvoice%
INPUT " and which voice "secondvoice%
FOR count% = firstvoice% TO secondvoice%
insts$(count%,0) = ""
NEXT
:
ENDPROC
:
REM***************************************************
:
DEF PROCcopyrhythm
:
REM copies disarray data from one voice to another directly
:
CLS
INPUT'" Copy rhythm from voice "fromvoice%
INPUT'" to voice "tovoice%
INPUT'" the passage starting at bar "frombar%
INPUT'" and ending with bar "tobar%
INPUT'" the copy to start at bar "copytobar%
diff% = copytobar% - frombar%
FOR count% = frombar% TO tobar%
disarray%(count%+diff%,0,tovoice%-1) = disarray%(count%,0,fromvoice%-1)
disarray%(count%+diff%,1,tovoice%-1) = disarray%(count%,1,fromvoice%-1)
disarray%(count%+diff%,2,tovoice%-1) = disarray%(count%,2,fromvoice%-1)
disarray%(count%+diff%,3,tovoice%-1) = disarray%(count%,3,fromvoice%-1)
NEXT
:
PROCdisplay
:
ENDPROC
:
REM****************************************************
:
DEF PROCquantize
:
FOR count% = 0 TO manyattacks%-1
    :
    proceed1$ = "yes"
    proceed2$ = "yes"
    REM routine to illimunate from quantizing attacks closer than 120 bts to adjacent attacks
    IF count% > 0 THEN
      value1% = (attacks2%(count%)MOD10^3) + ((attacks2%(count%)DIV10^3)*960)
      value2% = (attacks2%(count%-1)MOD10^3) + ((attacks2%(count%-1)DIV10^3)*960)
      IF (value1% - value2%) > 120 THEN proceed1$ = "yes" ELSE proceed1$ = "no"
    ENDIF
    :
    IF count%<(manyattacks%-1) THEN
      value1% = (attacks2%(count%)MOD10^3) + ((attacks2%(count%)DIV10^3)*960)
      value2% = (attacks2%(count%+1)MOD10^3) + ((attacks2%(count%+1)DIV10^3)*960)
      IF (value2% - value1%) > 120 THEN proceed2$ = "yes" ELSE proceed2$ = "no"
    ENDIF
    :
  IF proceed1$ = "yes" AND proceed2$ = "yes" THEN
  :
    beat% = attacks2%(count%)MOD10^3
    :
    IF beat%>900 AND beat%<960 THEN
      IF beat%<930 THEN
        attacks2%(count%) = (attacks2%(count%)-beat%+900)
      ELSE
        attacks2%(count%) = (attacks2%(count%)-beat%+1000)
        attacks3%(count%)+= 1000
      ENDIF
    ENDIF
    :
    IF beat%>0 AND beat%<60 THEN
      IF beat%<31 THEN
        attacks2%(count%)-=beat%
      ELSE
        attacks2%(count%) = (attacks2%(count%)-beat%+60)
      ENDIF
    ENDIF
    :
    IF beat%>420 AND beat%<480 THEN
      IF beat%<430 THEN
        attacks2%(count%)= (attacks2%(count%)-beat%+420)
      ELSE
        attacks2%(count%) = (attacks2%(count%)-beat%+480)
      ENDIF
    ENDIF
    :
    IF beat%>480 AND beat%<540 THEN
      IF beat%<511 THEN
        attacks2%(count%)= (attacks2%(count%)-beat%+480)
      ELSE
        attacks2%(count%) = (attacks2%(count%)-beat%+540)
      ENDIF
    ENDIF
    :
  ENDIF
  :
NEXT
:
ENDPROC
:
REM**************************************************************
:
DEF PROCreleases
 :
 IF easiermenus$ = "n" THEN PROCwindow(20,69,64,55) ELSE PROCwindow(20,69,64,42)
 CLS
 copymove$ = "C"
 :
IF quickcopy$ = "n" THEN
 INPUT'" Create envelope points for which voice "voice%
 IF voice% = 0 THEN PROCpressenter
 voice% -= 1
 INPUT'" Starting at bar "copystartbar%
 holdbar% = copystartbar%
 INPUT'"             beat "beats%
 PROCalterbeats : copystartbeat%   = beats%
 holdbeat% = copystartbeat%
 IF justone$ = "n" THEN
 PRINT'" Ending at bar "
 INPUT'" (for last type 0) "copyendbar%
 IF copyendbar% > 0 THEN
 INPUT '"           beat "beats%
 PROCalterbeats : copyendbeat% = beats%
 ENDIF
 ELSE
 copyendbar% = copystartbar%
 copyendbeat% = copystartbeat%
 ENDIF
 :
ELSE
 :
 INPUT'" Create envelope points for which voice "voice%
 IF voice% = 0 THEN PROCpressenter
 voice% -= 1
 INPUT '" note number "along%
 IF along% = 0 THEN along% = 1
 along%-=1
 copystartbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  copystartbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  holdbar% = copystartbar%
  holdbeat% = copystartbeat%
 IF justone$ = "n" THEN
 PRINT'" to note number "
 INPUT'" (for last type 0) "along%
 IF along% = 0 THEN
 copyendbar% = 0
 ELSE
 along%-=1
 copyendbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  copyendbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
 ENDIF
 ELSE
 copyendbar% = copystartbar%
 copyendbeat% = copystartbeat%
 ENDIF
ENDIF
 :
 :
 value% = (copystartbar%*10^3)+copystartbeat%
 IF value% <= array%(0,0,voice%)DIV10^3 THEN
  startatcell% = 0
 ELSE
 PROCsearch(value%)
 startatcell% = startcell%
 ENDIF
 IF copyendbar% = 0 THEN
 endatcell% = numusedcells%(voice%) - 1
 ELSE
 value% = (copyendbar%*10^3)+copyendbeat%
 IF value% >= array%(numusedcells%(voice%)-1,0,voice%)DIV10^3 THEN
  endatcell% = numusedcells%(voice%) - 1
 ELSE
 PROCsearch(value%)
 IF shunt$ = "N" THEN endatcell% = startcell% ELSE endatcell% = startcell% - 1
 ENDIF
 ENDIF
 :
 manyattacks% = endatcell% - startatcell% + 1
 REM create 'gap' between beat-of-bar and first actual attack
 carrybars% = (array%(startatcell%,0,voice%)DIV10^6)-copystartbar%
 carrybeats% = ((array%(startatcell%,0,voice%)DIV10^3)MOD10^3)-copystartbeat%
 attacks1%(0) = (carrybars%*960)+carrybeats%
 :
 FOR count% = 0 TO (manyattacks%-1)
  IF count% > 0 THEN
   carrybars% = (array%(startatcell%+count%,0,voice%)DIV10^6)-(array%(startatcell%+count%-1,0,voice%)DIV10^6)
   carrybeats% = ((array%(startatcell%+count%,0,voice%)DIV10^3)MOD10^3)-((array%(startatcell%+count%-1,0,voice%)DIV10^3)MOD10^3)
   attacks1%(count%) = attacks1%(count%-1) + ((carrybars%*960)+carrybeats%)
  ENDIF
 :
  pitches%(count%) = array%(startatcell%+count%,0,voice%)MOD10^3
  dur% = (array%(startatcell%+count%,1,voice%)DIV10)MOD10^3
    brrr% = array%(startatcell%+count%,0,voice%)DIV10^6 : PROCreconvertdur
    durations%(count%) = dur%
  NEXT
 :
 counter% = -1
 FOR count% = 0 TO (manyattacks%-1)
  :
  counter% += 1
  gliss1% = (array%(startatcell%+count%,1,voice%)DIV10^4)MOD10^2 : gliss1% = 50-gliss1%
  gliss2% = (array%(startatcell%+count%,1,voice%)DIV10^6)MOD10^2 : gliss2% = 50 - gliss2%
  gliss3% = array%(startatcell%+count%,1,voice%)DIV10^8 : gliss3% = 10 - gliss3%
  note% = pitches%(count%)DIV10^2
  accid% = (pitches%(count%)DIV10)MOD10
  oct% = pitches%(count%)MOD10
  :
  ph1% = ((array%(startatcell%+count%,2,voice%))DIV10^5)MOD10^2
  IF ph1% <> 0 THEN
   envattacks%(counter%) = attacks1%(count%)+(durations%(count%)*ph1%/100)
   gliss% = gliss1%
   IF gliss% <> 0 THEN
    PROCglisspitches
    envpitches%(counter%) = (note1%*100)+(accid1%*10)+oct1%
   ELSE
    envpitches%(counter%) = (note%*100)+(accid%*10)+oct%
   ENDIF
   :
  ENDIF
  :
  ph2% = (array%(startatcell%+count%,2,voice%))DIV10^7
  IF ph2% <> 0 THEN
   counter% += 1
   envattacks%(counter%) = attacks1%(count%)+(durations%(count%)*ph2%/100)
   gliss% = gliss1% + gliss2%
   IF gliss% <> 0 THEN
    PROCglisspitches
    envpitches%(counter%) = (note1%*100)+(accid1%*10)+oct1%
   ELSE
    envpitches%(counter%) = (note%*100)+(accid%*10)+oct%
   ENDIF
   :
  ENDIF
  :
  IF ph1% <> 0 THEN counter% += 1
   envattacks%(counter%) = attacks1%(count%)+durations%(count%)
   IF ph1% = 0 THEN gliss% = gliss1%
   IF ph1% <> 0 AND ph2% = 0 THEN gliss% = gliss1% + gliss2%
   IF ph2% <> 0 THEN gliss% = gliss1% + gliss2% + gliss3%
   IF gliss% <> 0 THEN
    PROCglisspitches
    envpitches%(counter%) = (note1%*100)+(accid1%*10)+oct1%
   ELSE
    envpitches%(counter%) = (note%*100)+(accid%*10)+oct%
   ENDIF
   :
 NEXT
  :
 FOR count% = 0 TO counter%
  :
  attacks1%(count%) = envattacks%(count%)
  pitches%(count%) = envpitches%(count%)
  durations%(count%) = 0
  amplitudes%(count%) = 0
  envelopes%(count%) = 9
  glissandos%(count%) = 105050
  inflections%(count%) = 50

 NEXT
  :
 numpitches% = counter% + 1
 manyattacks% = counter% + 1
 method$ = "raw"
 copyit$ = "ON"
 PROCinsertattacks
 :
 justone$ = "n"
 :
 ENDPROC
:
REM**********************************************
:
DEF PROCglisspitches
:
note1% = note% : accid1% = accid% : oct1% = oct%
:
IF gliss% < 0 THEN step% = -1 ELSE step% = 1
IF gliss% > 0 THEN startloop% = 1 ELSE startloop% = -1
:
FOR country% = startloop% TO gliss% STEP step%
:
 CASE step% OF
  WHEN -1 :
   CASE accid1% OF
    WHEN 1 :
     CASE note1% OF
      WHEN 0 :
       note1% = 6 : accid1% = 4 : oct1% -=1
      WHEN 1, 2, 4, 5, 6 :
       note1% -= 1 : accid1% = 8
      WHEN 3 :
       note1% -= 1 : accid1% = 4
     ENDCASE
    OTHERWISE accid1% -= 1
   ENDCASE
  WHEN 1 :
   CASE accid1% OF
    WHEN 9 :
     CASE note1% OF
      WHEN 0, 1, 3, 4, 5 :
       note1% += 1 : accid1% = 2
      WHEN 2 :
       note1% += 1 : accid1% = 6
      WHEN 6 :
       note1% = 0 : accid1% = 6 : oct1% += 1
     ENDCASE
    OTHERWISE accid1% += 1
   ENDCASE
 ENDCASE
NEXT
:
ENDPROC
:
REM*********************************************
:
DEF PROCdoublestop
 :
IF easiermenus$ = "n" THEN PROCwindow(20,69,96,54) ELSE PROCwindow(20,69,96,42)
 repeatposit$ = "n"
 distort$ = "OFF"
 dothis$ = "YES"
 :
 copymove$ = "DS"
 savevoice$ = "N"
 justone$ = "n"
 :
PRINT'" Violin, viola, cello or bass (N,A,O,S)? "
PRINT'" (or press E for an explanation of the function) "
CASE GET$ OF
 WHEN "N","n" : member$ = "violin"
 WHEN "A","a" : member$ = "viola"
 WHEN "O","o" : member$ = "cello"
 WHEN "S","s" : member$ = "bass"
 WHEN "E","e" :
 IF easiermenus$ = "n" THEN PROCwindow(8,71,96,54) ELSE PROCwindow(11,69,96,42)
 VDU 14
CLS
PRINT'" The typical situation in which the double-stop function would play a part"
PRINT" is imagined to be this: up to four voices are employed to schedule attack-points "
PRINT" on each of the strings (at this stage make a single-voice reduction with the attacks "
PRINT" pitched on the open strings, because this will be needed in the function). "
PRINT'" Pitches are allocated to the attacks, including open strings and harmonics, with "
PRINT" the condition that all are within a single lh position at any one time. "
PRINT'" Now reduce these separate-string voices to a single voice - this is treated by "
PRINT" the function to produce a version inserting practical double-stops according to "
PRINT" user-defined probabilities; this is copied into two further voices to enable faithful "
PRINT" play-back; durations are correctly clipped, so a further reduction of these two "
PRINT" voices will give a clear indication of notation on a single stave. "
PRINT'" (press C to continue) "
CASE GET$ OF
ENDCASE
VDU 15
PROCdisplay
 OTHERWISE PROCdoublestop
ENDCASE
INPUT'" Which single voice is to be treated? "treatvoice%
 treatvoice% -= 1
INPUT'" Which other 2 voices is it divided into? - voice... "firstvoice%
 firstvoice% -= 1
INPUT'" and voice... "secondvoice%
 secondvoice% -= 1
INPUT'" And which single voice carries the open strings? - voice... "stringvoice%
 stringvoice% -= 1
CLS
PRINT''" These 4 voices are assumed to correspond vertically; "
 INPUT'" the passage is to start at bar "copystartbar%
IF copystartbar% = 0 THEN
 copystartbar% = holdbar% : copystartbeat% = holdbeat% : repeatposit$ = "y"
ENDIF
 holdbar% = copystartbar%
IF repeatposit$ = "y" THEN
 PRINT'" bar ";copystartbar%;" beat ";copystartbeat%;"?"
 PRINT" (for OK press 0, if not OK press X)"
 CASE GET$ OF
  WHEN"X","x" : PROCdoublestop
  OTHERWISE
 ENDCASE
ELSE
 INPUT"             beat "beats%
ENDIF
 PROCalterbeats : copystartbeat%   = beats%
 holdbeat% = copystartbeat%
 IF justone$ = "n" THEN
 PRINT'" Ending at bar "
 INPUT" (for last type 0) "copyendbar%
 IF copyendbar% > 0 THEN
 INPUT "           beat "beats%
 PROCalterbeats : copyendbeat% = beats%
 ENDIF
 ELSE
 copyendbar% = copystartbar%
 copyendbeat% = copystartbeat%
 ENDIF
 :
 CLS
 PRINT'" On what percentage of occasions do you want a potential "
 PRINT" double-stop to be allowed? "
 INPUT'" (a) following a single-stop... "singlechance%
 INPUT'" (b) following a double-stop... "doublechance%
 :
 FOR run% = 0 TO 1
 IF run% = 0 THEN voice% = stringvoice% ELSE voice% = treatvoice%
 value% = (copystartbar%*10^3)+copystartbeat%
 IF value% <= array%(0,0,voice%)DIV10^3 THEN
  startatcell% = 0
 ELSE
 PROCsearch(value%)
 startatcell% = startcell%
 ENDIF
 IF copyendbar% = 0 THEN
 endatcell% = numusedcells%(voice%) - 1
 ELSE
 value% = (copyendbar%*10^3)+copyendbeat%
 IF value% >= array%(numusedcells%(voice%)-1,0,voice%)DIV10^3 THEN
  endatcell% = numusedcells%(voice%) - 1
 ELSE
 PROCsearch(value%)
 IF shunt$ = "N" THEN endatcell% = startcell% ELSE endatcell% = startcell% - 1
 ENDIF
 ENDIF
 :
 manyattacks% = endatcell% - startatcell% + 1
 REM create 'gap' between beat-of-bar and first actual attack
 carrybars% = (array%(startatcell%,0,voice%)DIV10^6)-copystartbar%
 carrybeats% = ((array%(startatcell%,0,voice%)DIV10^3)MOD10^3)-copystartbeat%
 attacks1%(0) = (carrybars%*960)+carrybeats%
 :
 IF copymove$ = "DS" THEN
 FOR count% = 0 TO (manyattacks%-1)
  IF count% > 0 THEN
   carrybars% = (array%(startatcell%+count%,0,voice%)DIV10^6)-(array%(startatcell%+count%-1,0,voice%)DIV10^6)
   carrybeats% = ((array%(startatcell%+count%,0,voice%)DIV10^3)MOD10^3)-((array%(startatcell%+count%-1,0,voice%)DIV10^3)MOD10^3)
   attacks1%(count%) = attacks1%(count%-1) + ((carrybars%*960)+carrybeats%)
  ENDIF
 :
  pitches%(count%) = array%(startatcell%+count%,0,voice%)MOD10^3
  IF run% = 0 THEN
   pitch% = pitches%(count%)
   PROCopenstgs
  ENDIF
  dur% = (array%(startatcell%+count%,1,voice%)DIV10)MOD10^3
    brrr% = array%(startatcell%+count%,0,voice%)DIV10^6 : PROCreconvertdur
    durations%(count%) = dur%
  amplitudes%(count%) = (array%(startatcell%+count%,1,voice%))MOD10
  envelopes%(count%) = (array%(startatcell%+count%,2,voice%))DIV10^2
  glissandos%(count%) = (array%(startatcell%+count%,1,voice%)DIV10^4)
  inflections%(count%) = array%(startatcell%+count%,2,voice%)MOD10^2
 NEXT
 ENDIF
 NEXT run%
 :
 :
 firstcutoff% = 0
 secondcutoff% = 0
 :
 FOR count% = 0 TO (manyattacks%-1)
 :
 REM determine state before making decision
 state$ = "tacet"
 IF firstcutoff% > attacks1%(count%) THEN state$ = "single1"
 IF secondcutoff% > attacks1%(count%) AND state$ = "tacet" THEN state$ = "single2"
 IF secondcutoff% > attacks1%(count%) AND state$ = "single1" THEN state$ = "double"
 :
 CASE state$ OF
   WHEN "tacet" :
     dsvoice%(count%) = firstvoice%
     firstcutoff% = attacks1%(count%) + durations%(count%)
     firstcount% = count%
     firststg% = openstgs%(count%)
     :
   WHEN "single1" :
     newstg$ = "nonadj"
     IF firststg% = openstgs%(count%) THEN newstg$ = "same"
     IF firststg% = (openstgs%(count%)-1) OR firststg% = (openstgs%(count%)+1) THEN newstg$ = "adj"
     :
     CASE newstg$ OF
       WHEN "same" :
         dsvoice%(count%) = firstvoice%
         firstcutoff% = attacks1%(count%) + durations%(count%)
         firststg% = openstgs%(count%)
         REM clip duration of interrupted note
         durations%(firstcount%) = attacks1%(count%) - attacks1%(firstcount%)
         firstcount% = count%
       WHEN "adj" :
         PROCsingleprob
         IF ds$ = "n" THEN
           dsvoice%(count%) = firstvoice%
           firstcutoff% = attacks1%(count%) + durations%(count%)
           firststg% = openstgs%(count%)
           REM clip duration of interrupted note
           durations%(firstcount%) = attacks1%(count%) - attacks1%(firstcount%)
           firstcount% = count%
         ELSE
           dsvoice%(count%) = secondvoice%
           secondcutoff% = attacks1%(count%) + durations%(count%)
           secondcount% = count%
           secondstg% = openstgs%(count%)
         ENDIF
       WHEN "nonadj" :
           dsvoice%(count%) = firstvoice%
           firstcutoff% = attacks1%(count%) + durations%(count%)
           firststg% = openstgs%(count%)
           REM clip duration of interrupted note and add slight 'rest'
           durations%(firstcount%) = attacks1%(count%) - (attacks1%(firstcount%)+60)
           IF durations%(firstcount%) <0 THEN durations%(firstcount%) = 1
           firstcount% = count%
     ENDCASE
     :
   WHEN "single2" :
     newstg$ = "nonadj"
     IF secondstg% = openstgs%(count%) THEN newstg$ = "same"
     IF secondstg% = (openstgs%(count%)-1) OR secondstg% = (openstgs%(count%)+1) THEN newstg$ = "adj"
     :
     CASE newstg$ OF
       WHEN "same" :
         dsvoice%(count%) = secondvoice%
         secondcutoff% = attacks1%(count%) + durations%(count%)
         secondstg% = openstgs%(count%)
         REM clip duration of interrupted note
         durations%(secondcount%) = attacks1%(count%) - attacks1%(secondcount%)
         secondcount% = count%
       WHEN "adj" :
         PROCsingleprob
         IF ds$ = "n" THEN
           dsvoice%(count%) = secondvoice%
           secondcutoff% = attacks1%(count%) + durations%(count%)
           secondstg% = openstgs%(count%)
           REM clip duration of interrupted note
           durations%(secondcount%) = attacks1%(count%) - attacks1%(secondcount%)
           secondcount% = count%
         ELSE
           dsvoice%(count%) = firstvoice%
           firstcutoff% = attacks1%(count%) + durations%(count%)
           firstcount% = count%
           firststg% = openstgs%(count%)
         ENDIF
       WHEN "nonadj" :
           dsvoice%(count%) = secondvoice%
           secondcutoff% = attacks1%(count%) + durations%(count%)
           secondstg% = openstgs%(count%)
           REM clip duration of interrupted note and add slight 'rest'
           durations%(secondcount%) = attacks1%(count%) - (attacks1%(secondcount%)+60)
           IF durations%(secondcount%) <0 THEN durations%(secondcount%) = 1
           secondcount% = count%
     ENDCASE
     :

   WHEN "double" :
     newstg$ = "nonadj"
     IF openstgs%(count%) = firststg% THEN newstg$ = "sameasfirst"
     IF openstgs%(count%) = secondstg% THEN newstg$ = "sameassecond"
     IF (openstgs%(count%) = (firststg%-1) OR openstgs%(count%) = (firststg%+1)) AND openstgs%(count%) <> secondstg% THEN newstg$ = "adjtofirst"
     IF (openstgs%(count%) = (secondstg%-1) OR openstgs%(count%) = (secondstg%+1)) AND openstgs%(count%) <> firststg% THEN newstg$ = "adjtosecond"
     :
     CASE newstg$ OF
       WHEN "sameasfirst" :
         PROCdoubleprob
           IF ds$ = "n" THEN
              dsvoice%(count%) = firstvoice%
              firstcutoff% = attacks1%(count%) + durations%(count%)
              firststg% = openstgs%(count%)
              REM clip durations of both interrupted notes
              durations%(firstcount%) = attacks1%(count%) - attacks1%(firstcount%)
              firstcount% = count%
              durations%(secondcount%) = attacks1%(count%) - attacks1%(secondcount%)
              secondcutoff% = attacks1%(secondcount%) + durations%(secondcount%)
           ELSE
              dsvoice%(count%) = firstvoice%
              firstcutoff% = attacks1%(count%) + durations%(count%)
              firststg% = openstgs%(count%)
              REM clip duration of interrupted note
              durations%(firstcount%) = attacks1%(count%) - attacks1%(firstcount%)
              firstcount% = count%
           ENDIF
       WHEN "sameassecond" :
         PROCdoubleprob
           IF ds$ = "n" THEN
              dsvoice%(count%) = secondvoice%
              secondcutoff% = attacks1%(count%) + durations%(count%)
              secondstg% = openstgs%(count%)
              REM clip durations of both interrupted notes
              durations%(secondcount%) = attacks1%(count%) - attacks1%(secondcount%)
              secondcount% = count%
              durations%(firstcount%) = attacks1%(count%) - attacks1%(firstcount%)
              firstcutoff% = attacks1%(firstcount%) + durations%(firstcount%)
           ELSE
              dsvoice%(count%) = secondvoice%
              secondcutoff% = attacks1%(count%) + durations%(count%)
              secondstg% = openstgs%(count%)
              REM clip duration of interrupted note
              durations%(secondcount%) = attacks1%(count%) - attacks1%(secondcount%)
              secondcount% = count%
           ENDIF
       WHEN "adjtofirst" :
         PROCdoubleprob
         IF ds$ = "n" THEN
              dsvoice%(count%) = firstvoice%
              firstcutoff% = attacks1%(count%) + durations%(count%)
              firststg% = openstgs%(count%)
              REM clip durations of both interrupted notes
              durations%(firstcount%) = attacks1%(count%) - attacks1%(firstcount%)
              firstcount% = count%
              durations%(secondcount%) = attacks1%(count%) - attacks1%(secondcount%)
              secondcutoff% = attacks1%(secondcount%) + durations%(secondcount%)
         ELSE
              dsvoice%(count%) = secondvoice%
              secondcutoff% = attacks1%(count%) + durations%(count%)
              secondstg% = openstgs%(count%)
              REM clip duration of interrupted note
              durations%(secondcount%) = attacks1%(count%) - attacks1%(secondcount%)
              secondcount% = count%
         ENDIF
       WHEN "adjtosecond" :
          PROCdoubleprob
            IF ds$ = "n" THEN
              dsvoice%(count%) = secondvoice%
              secondcutoff% = attacks1%(count%) + durations%(count%)
              secondstg% = openstgs%(count%)
              REM clip durations of both interrupted notes
              durations%(secondcount%) = attacks1%(count%) - attacks1%(secondcount%)
              secondcount% = count%
              durations%(firstcount%) = attacks1%(count%) - attacks1%(firstcount%)
              firstcutoff% = attacks1%(firstcount%) + durations%(firstcount%)
         ELSE
              dsvoice%(count%) = firstvoice%
              firstcutoff% = attacks1%(count%) + durations%(count%)
              firststg% = openstgs%(count%)
              REM clip duration of interrupted note
              durations%(firstcount%) = attacks1%(count%) - attacks1%(firstcount%)
              firstcount% = count%
         ENDIF
       WHEN "nonadj" :
              dsvoice%(count%) = firstvoice%
              firstcutoff% = attacks1%(count%) + durations%(count%)
              firststg% = openstgs%(count%)
              REM clip durations of both interrupted notes and add 'rests'
              durations%(firstcount%) = attacks1%(count%) - (attacks1%(firstcount%)+60)
              IF durations%(firstcount%) <0 THEN durations%(firstcount%) = 1
              firstcount% = count%
              durations%(secondcount%) = attacks1%(count%) - (attacks1%(secondcount%)+60)
              IF durations%(secondcount%) <0 THEN durations%(secondcount%) = 1
              secondcutoff% = attacks1%(secondcount%) + durations%(secondcount%)
     ENDCASE
     :
 ENDCASE
 :
 NEXT
 :
 :
 numpitches% = manyattacks% : method$ = "raw" : copyit$ = "ON" : justone$ = "n"
: repeatposit$ = "n" : reordered$ = "n" : equalized$ = "n" : rhythmicized$ = "n"
:
 : startat% = (copystartbar%*(10^3))+copystartbeat%

 attacks2%() = attacks1%()
 :
 attacks2%() = attacks2%() + (startat% MOD 10^3) : REM moves attacks further up bar, if necc
 :
 attacks3%() = attacks2%()
 FOR count% = 0 TO (manyattacks%-1)
  attacks3%(count%) = attacks3%(count%) DIV 960
 NEXT
 REM gives list of bar mos starting at 0
 :
 attacks3%() = attacks3%() * 960
 attacks2%() = attacks2%() - attacks3%()
 attacks3%() = attacks3%() / 960
 REM list of actual beat numbers
 :
 attacks3%() = attacks3%() + (startat% DIV 10^3) : REM list of actual bar nos
 :
 attacks3%() = attacks3%()*(10^3)
 attacks2%() = attacks2%() + attacks3%()
 REM list of actual bar/beat numbers
 :
 :
 addingnotes$ = "y"
 :
   FOR counter% = 0 TO (manyattacks%-1)
    voice% = dsvoice%(counter%)
    PROCnewnotereception(voice%, (attacks2%(counter%)DIV10^3), (attacks2%(counter%)MOD10^3), pitches%(counter%), amplitudes%(counter%), envelopes%(counter%), durations%(counter%), glissandos%(counter%), inflections%(counter%))
   NEXT
 :
 copyit$ = "OFF" : displayedfunc$ = "n" : PROCdisplay
:
 ENDPROC
:
REM******************************************************************
:
DEF PROCopenstgs
:
CASE member$ OF
 WHEN "violin" :
  CASE pitch% OF
   WHEN 255 : openstgs%(count%) = 1
   WHEN 554 : openstgs%(count%) = 2
   WHEN 154 : openstgs%(count%) = 3
   WHEN 453 : openstgs%(count%) = 4
   OTHERWISE
   VDU 7 : PRINT "NOT AN OPEN STRING"
   PRINT "press C to continue"
   CASE GET$ OF
   ENDCASE
   PROCdoublestop
  ENDCASE
  :
  WHEN "viola" :
  CASE pitch% OF
   WHEN 554 : openstgs%(count%) = 1
   WHEN 154 : openstgs%(count%) = 2
   WHEN 453 : openstgs%(count%) = 3
   WHEN 53 : openstgs%(count%) = 4
   OTHERWISE
   VDU 7 : PRINT "NOT AN OPEN STRING"
   PRINT "press C to continue"
   CASE GET$ OF
   ENDCASE
   PROCdoublestop
  ENDCASE
  :
  WHEN "cello" :
  CASE pitch% OF
   WHEN 553 : openstgs%(count%) = 1
   WHEN 153 : openstgs%(count%) = 2
   WHEN 452 : openstgs%(count%) = 3
   WHEN 52 : openstgs%(count%) = 4
   OTHERWISE
   VDU 7 : PRINT "NOT AN OPEN STRING"
   PRINT "press C to continue"
   CASE GET$ OF
   ENDCASE
   PROCdoublestop
  ENDCASE
  :
  WHEN "bass" :
  CASE pitch% OF
   WHEN 452 : openstgs%(count%) = 1
   WHEN 152 : openstgs%(count%) = 2
   WHEN 551 : openstgs%(count%) = 3
   WHEN 251 : openstgs%(count%) = 4
   OTHERWISE
   VDU 7 : PRINT "NOT AN OPEN STRING"
   PRINT "press C to continue"
   CASE GET$ OF
   ENDCASE
   PROCdoublestop
  ENDCASE
  :
 ENDCASE
 :
 ENDPROC
 :
 REM****************************************************
:
DEF PROCsingleprob
:
number% = RND(100)
IF number% > 0 AND number% <= singlechance% THEN
ds$ = "y"
ELSE
ds$ = "n"
ENDIF
ENDPROC
:
REM***************************************************
:
DEF PROCdoubleprob
:
number% = RND(100)
IF number% > 0 AND number% <= doublechance% THEN
ds$ = "y"
ELSE
ds$ = "n"
ENDIF
ENDPROC
:
REM***************************************************
:
DEF PROCsamepitches
:
  PRINT' " Note name for pitch is ";
 COLOUR 3
  CASE GET$ OF
   WHEN "C","c" : note% = 0 : PRINT "C"
   WHEN "D","d" : note% = 1 : PRINT "D"
   WHEN "E","e" : note% = 2 : PRINT "E"
   WHEN "F","f" : note% = 3 : PRINT "F"
   WHEN "G","g" : note% = 4 : PRINT "G"
   WHEN "A","a" : note% = 5 : PRINT "A"
   WHEN "B","b" : note% = 6 : PRINT "B"
  ENDCASE
 COLOUR 0
  PRINT "               accidental ";

 COLOUR 3
  CASE GET$ OF
   WHEN "1" : accid% = 1 : PRINT "flat"
   WHEN "2" : accid% = 2 : PRINT "3/8flat"
   WHEN "3" : accid% = 3 : PRINT "1/4flat"
   WHEN "4" : accid% = 4 : PRINT "1/8flat"
   WHEN "5" : accid% = 5 : PRINT "nat"
   WHEN "6" : accid% = 6 : PRINT "1/8shrp"
   WHEN "7" : accid% = 7 : PRINT "1/4shrp"
   WHEN "8" : accid% = 8 : PRINT "3/8shrp"
   WHEN "9" : accid% = 9 : PRINT "shrp"
  ENDCASE
 COLOUR 0
  PRINT "                   octave ";
 COLOUR 3
  CASE GET$ OF
   WHEN "0" : octave% = 0 : PRINT "0"
   WHEN "1" : octave% = 1 : PRINT "1"
   WHEN "2" : octave% = 2 : PRINT "2"
   WHEN "3" : octave% = 3 : PRINT "3"
   WHEN "4" : octave% = 4 : PRINT "4"
   WHEN "5" : octave% = 5 : PRINT "5"
   WHEN "6" : octave% = 6 : PRINT "6"
   WHEN "7" : octave% = 7 : PRINT "7"
   WHEN "8" : octave% = 8 : PRINT "8"
  ENDCASE
 COLOUR 0
FOR count% = 0 TO numpitches% - 1
 pitches%(count%) = (note%*100)+(accid%*10)+octave%
 NEXT
 :
 firstpitch$ = "n" : prevnumpitches% = numpitches%
 REM function can feed pitches similarly into pitches%
 :
 PROCinsertpitches
 :
 ENDPROC
:
REM*************************************************
:
DEF PROCedit
:
PROCwindow(20,60,58,39)
PRINT ' " move 1st envelope point          E"
PRINT '  " move 2nd envelope point          R"
PRINT '  " change 1st amplitude             A"
PRINT '  " change 2nd amplitude             S"
PRINT '  " change 3rd amplitude             D"
PRINT '  " change 4th amplitude             F"
PRINT '  " move note+following note         N"
PRINT '  " move note+drag previous duration M"
PRINT '  " change duration                  C"
PRINT ' " then Shift + < OR >"
CASE GET$ OF
WHEN "E", "e" : editwhat$ = "1stenvelope"
WHEN "R", "r" : editwhat$ = "2ndenvelope"
WHEN "A", "a" : editwhat$ = "1stamplitude"
WHEN "S", "s" : editwhat$ = "2ndamplitude"
WHEN "D", "d" : editwhat$ = "3rdamplitude"
WHEN "F", "f" : editwhat$ = "4thamplitude"
WHEN "N", "n" : editwhat$ = "movetwo"
WHEN "M", "m" : editwhat$ = "move&drag"
WHEN "C", "c" : editwhat$ = "duration"
ENDCASE
PROCdisplay
ENDPROC
:
REM*************************************************
:
DEF PROCconvertoldenvelopes
:
REM When a/dal niente was introduced, notes with amp2%=0 had to display an envelope
REM whereas previously amp2%=0 meant "no envelope"
REM Consequently files predating this change now undesirably display "no envelope" notes as single-phase "dim a niente" notes
REM To update the old files, use this proc to give a value amp2%=9 to all notes
PROCwindow(20,60,68,45)
PRINT' " Do you want to convert all the envelopes"
PRINT" in the file back to 0 phase envelopes?"
CASE GET$ OF
 WHEN "Y", "y" :
 FOR voice% = 0 TO (numparts%-1)
  :
  FOR count% = 0 TO numusedcells%(voice%)-1
   number% = array%(count%,2,voice%) DIV 10^2
   array%(count%,2,voice%) = array%(count%,2,voice%) - (number%*100)
   array%(count%,2,voice%) = array%(count%,2,voice%) + 900
  NEXT
  :
 NEXT
 PROCdisplay
 OTHERWISE PROCdisplay
ENDCASE
ENDPROC
:
REM************************************************
:
DEF PROCkeyboardshortcuts
:
PROCwindow(2,68,97,2)
:
PRINT ' " Menu                         M             Accel/rit by total duration          T"
PRINT ' " Display menu                 O             Accel/rit by start/end points        E"
PRINT ' " Move down 1, 3/10, x many, 50 v/vv/vx/v0   Accel/rit between adjacent notes     F"
PRINT ' " Move up 1, 3/10, x many, 50   ^/^^/^x/^0   Starting note for F above            1,2,3..."
PRINT ' " Move left                    </<</<9       Random number/with same values     n/N"
PRINT ' " Move right                   >/>>/>9       Group of durations                   U"
PRINT ' " Go to bar                    B             Quickplay top x voices (see M-V-Q)   P"
PRINT ' " Go to SECTION                S             Quickplay 2nd voice only             ;"
PRINT ' " Display x number of bars     D             Quickplay 3rd voice only             /"
PRINT ' " Double number of bars        +             Quickplay top x voices, screen only ^P"
PRINT ' " Halve number of bars         -             Quickplay 2nd voice, screen only     :"
PRINT ' " Quick display                Q             Quickplay 3rd voice, screem only     ?"
PRINT ' " Prev Quick/Quick/Ord Display W             Replay                               R"
PRINT ' " Top remarks left/right       [/]           Slavevoice function                 ^L"
PRINT ' " Bottom remarks left/right    '/#           Edit envelope voice 1, note 1,2,3... ^QWER..."
PRINT ' " [free keystroke]             ~             Edit envelope voice 2, note 1,2,3... ^ASDF..."
PRINT ' " Menus easier to read         @             Edit envelope voice 3, note 1,2,3... ^ZXCV..."
PRINT ' " Hard copy                    H             Enter last value again               Return"
PRINT ' " Name staves                 ^V             Import                              ^I"
PRINT ' " Accel/rit                    A             Group of attacks                     0"
PRINT ' " Group of amplitudes          L             Group of envelopes                   J"
PRINT ' " Show keyboard shortcuts      K             Move a passage                       \"
PRINT ' " Distort attacks/pitches      `/``          Move one note                       ^\"
PRINT ' " Increment calculator         C             Copy one note                        Z"
PRINT ' " Group of pitches             Y             Copy a passage                       X"
PRINT ' " Copy note x down 1/x stave(s)^x/^xx        Quickdisplay x voices         1,2,3..."
PRINT ' " Delete note 1/x top stave    ^O/^Ox        Delete sim middle/bottom staves      ^K/^M"
PRINT ' " [free keystroke]             #             Extract                              I"
PRINT ' " Fill gaps with durations     G             Copy successive voices to same voice  S"
PRINT ' " Add 0/10/20 to copying down  [/]/'         Input screen voice       Return 1/2/3 times"
PRINT ' " Display all voices           ^=            Display from which voice down        �"
PRINT ' " Quick copy on                {             Quick copy off                       }"
PRINT ' "                           (press a key to continue)"
CASE GET$ OF
WHEN "c", "C" :
PROCdisplay
OTHERWISE
PROCdisplay
ENDCASE
:
ENDPROC
:
REM***************************************************************************************
:
DEF PROCmoveback
:
INPUT " Move back by how many bars "backbybars%
INPUT " and how many beats "backby%
backby% = backby%+(backbybars%*960)
:
IF backby% = 0 THEN
COLOUR 3 : PRINT' holdbackby%;"?"
CASE GET$ OF
 WHEN "N","n" : COLOUR 0 : PROCmoveback
 OTHERWISE backby% = holdbackby%
ENDCASE
COLOUR 0
ENDIF
:
holdbackby% = backby%
beats% = beats% - backby%
REPEAT
IF beats% < 0 THEN
REPEAT
beats% = 960 + beats%
bars% -= 1
UNTIL beats% >= 0
ENDIF
:
ENDPROC
:
REM******************************************************************************************
:
DEF PROCmoveforward
:
INPUT " Move forward by how many bars "backbybars%
INPUT " and how many beats "backby%
backby% = backby%+(backbybars%*960)
:
IF backby% = 0 THEN
COLOUR 3 : PRINT' holdbackby%;"?"
CASE GET$ OF
 WHEN "N","n" : COLOUR 0 : PROCmoveforward
 OTHERWISE backby% = holdbackby%
ENDCASE
COLOUR 0
ENDIF
:
holdbackby% = backby%
beats% = beats% + backby%
REPEAT
IF beats% > 960 THEN
REPEAT
beats% = beats% - 960
bars% += 1
UNTIL beats% <= 960
ENDIF
:
ENDPROC
:
REM******************************************************************************************
:
DEF PROCpitchstring3
:
IF easiermenus$ = "n" THEN PROCwindow(20,69,60,55) ELSE PROCwindow(20,69,60,42)
PRINT'" Return a random pitch-class having"
PRINT" pre-defined its probability "
PRINT'" Use previous shares or re-define (P/R)? "
CASE GET$ OF
 WHEN "r","R" :
:
totalshares% = 0
INPUT '" C nat has how many shares "many%
cnat% = 0 + many% : totalshares% += many%
INPUT '" C sharp has how many shares "many%
cshrp% = cnat% + many% : totalshares% += many%
INPUT '" D nat has how many shares "many%
dnat% = cshrp% + many% : totalshares% += many%
INPUT '" D sharp has how many shares "many%
dshrp% = dnat% + many% : totalshares% += many%
INPUT '" E nat has how many shares "many%
enat% = dshrp% + many% : totalshares% += many%
INPUT '" F nat has how many shares "many%
fnat% = enat% + many% : totalshares% += many%
INPUT '" F sharp has how many shares "many%
fshrp% = fnat% + many% : totalshares% += many%
INPUT '" G nat has how many shares "many%
gnat% = fshrp% + many% : totalshares% += many%
INPUT '" G sharp has how many shares "many%
gshrp% = gnat% + many% : totalshares% += many%
INPUT '" A nat has how many shares "many%
anat% = gshrp% + many% : totalshares% += many%
INPUT '" A sharp has how many shares "many%
ashrp% = anat% + many% : totalshares% += many%
INPUT '" B nat has how many shares "many%
bnat% = ashrp% + many% : totalshares% += many%
OTHERWISE
ENDCASE
throw% = RND(totalshares%)
IF throw% > 0 AND throw% <= cnat% THEN note$ = "C nat"
IF throw% > cnat% AND throw% <= cshrp% THEN note$ = "C sharp"
IF throw% > cshrp% AND throw% <= dnat% THEN note$ = "D nat"
IF throw% > dnat% AND throw% <= dshrp% THEN note$ = "D sharp"
IF throw% > dshrp% AND throw% <= enat% THEN note$ = "E nat"
IF throw% > enat% AND throw% <= fnat% THEN note$ = "F nat"
IF throw% > fnat% AND throw% <= fshrp% THEN note$ = "F sharp"
IF throw% > fshrp% AND throw% <= gnat% THEN note$ = "G nat"
IF throw% > gnat% AND throw% <= gshrp% THEN note$ = "G sharp"
IF throw% > gshrp% AND throw% <= anat% THEN note$ = "A nat"
IF throw% > anat% AND throw% <= ashrp% THEN note$ = "A sharp"
IF throw% > ashrp% AND throw% <= bnat% THEN note$ = "B nat"

PRINT ''" note = ";note$
PRINT '" use this? "
CASE GET$ OF
WHEN "n","N" :
PROCpitchstring3
OTHERWISE
ENDCASE
INPUT'" which octave "octave%
IF octave% > 0 THEN sameoctave% = octave%
IF octave% = 0 THEN octave% = sameoctave%
CASE note$ OF
 WHEN "C nat" : note% = 0 : accid% = 5 : octave% = octave%
 WHEN "C sharp" : note% = 0 : accid% = 9 : octave% = octave%
 WHEN "D nat" : note% = 1 : accid% = 5 : octave% = octave%
 WHEN "D sharp" : note% = 1 : accid% = 9 : octave% = octave%
 WHEN "E nat" : note% = 2 : accid% = 5 : octave% = octave%
 WHEN "F nat" : note% = 3 : accid% = 5 : octave% = octave%
 WHEN "F sharp" : note% = 3 : accid% = 9 : octave% = octave%
 WHEN "G nat" : note% = 4 : accid% = 5 : octave% = octave%
 WHEN "G sharp" : note% = 4 : accid% = 9 : octave% = octave%
 WHEN "A nat" : note% = 5 : accid% = 5 : octave% = octave%
 WHEN "A sharp" : note% = 5 : accid% = 9 : octave% = octave%
 WHEN "B nat" : note% = 6 : accid% = 5 : octave% = octave%
ENDCASE
numpitches% = 1 : pitches%(0) = (note%*100)+(accid%*10)+octave%
PROCinsertpitches
:
ENDPROC
:
REM******************************************************************
:
DEF PROCincrementcalc
:
PROCwindow(15,71,89,45)
CLS
:
PRINT'" As it is written, Accel/Rit allows no.attacks and rate"
PRINT" to be defined in one mode, or start/finish durs in the other"
PRINT" but not start dur AND a defined rate together (and just to"
PRINT" complicate things, the resultant rate in fact varies in different"
PRINT" contexts). If you want, say, a closely defined quickend and"
PRINT" also a closely defined rate of rit, to get this in accel/Rit"
PRINT" you will also need to know IN ADVANCE what the end dur will be"
PRINT" so as to input this when using Accel/Rit in its second mode."
PRINT" The proceedure below is for finding precisely this."
:
count% = 1
INPUT'" First type the start duration "value
PRINT'" then the arithmetic rate of increment (not the Accel/Rit rate)"
INPUT" as a decimal number "factor
total% = value
INPUT'" and finally the total duration "reqtotal%
PRINT'" (then press a key for successive increments)"
PRINT'count%;". duration = ";value;" total = ";total%
REPEAT
CASE GET$ OF
OTHERWISE
count% += 1
value = value * factor
total% = total% + value
gap% = reqtotal% - total%
value% = value DIV 1
PRINT'count%;". duration = ";value%;" total = ";total%;" (";gap%;" short of required total)"
ENDCASE
UNTIL gap% <0
:
PRINT'" (to return to display press F)"
REPEAT
key$ = GET$
IF key$ = "f" THEN PROCdisplay ELSE VDU 7
UNTIL key$ = "f"
ENDPROC
:
REM*********************************************************************************
:
DEF PROCchangeclef
:
REM IF easiermenus$ = "n" THEN PROCwindow(20,69,65,55) ELSEPROCwindow(20,69,65,42)
CLS
INPUT'" Change clef for which voice "itsvoice%
INPUT'" How many staves does this voice have "numstaves$
PRINT'" And what is/are its clefs (P/T/B/D or"
INPUT"  PP/PT etc.) "clef$
:
insts$(itsvoice%,2) = numstaves$
insts$(itsvoice%,1) = clef$
:
ENDPROC
:
REM**********************************************************************************
:
DEF PROCrandomassign
:
CLS
INPUT'" between voice "first%
IF first% = 0 THEN firs% = 1
INPUT'" and voice (for last press 0) "last%
IF last% = 0 THEN last% = numparts%
:
INPUT '" using how many of the 19 voices "no%
taken%() = 0
:
FOR count% = 1 TO no%
 result$ = "failure"
 REPEAT
  voice% = RND(19)
  IF taken%(voice%) = 0 THEN
   taken%(voice%) = 1
   result$ = "success"
  ENDIF
 UNTIL result$ = "success"
NEXT
:
FOR count% = first% TO last%
 REPEAT
 x% = RND(19)
 UNTIL taken%(x%) = 1
 :
 CASE x% OF
  WHEN 1 : IF type$ = "drums" THEN waveforms$(count%) = "Timpani" ELSE waveforms$(count%) = "RecorderGb"
  WHEN 2 : IF type$ = "drums" THEN waveforms$(count%) = "TimpCresBb" ELSE waveforms$(count%) = "PiccoloE"
  WHEN 3 : IF type$ = "drums" THEN waveforms$(count%) = "TimpRollEb" ELSE waveforms$(count%) = "SaxSoprnoE"
  WHEN 4 : IF type$ = "drums" THEN waveforms$(count%) = "TimpLowBb" ELSE waveforms$(count%) = "SaxEbBarC"
  WHEN 5 : IF type$ = "drums" THEN waveforms$(count%) = "BassDrum" ELSE waveforms$(count%) = "SaxBbTenrE"
  WHEN 7 : IF type$ = "drums" THEN waveforms$(count%) = "BDGatedRev" ELSE waveforms$(count%) = "BugleC"
  WHEN 8 : IF type$ = "drums" THEN waveforms$(count%) = "BDMarching" ELSE waveforms$(count%) = "Trombone1"
  WHEN 9 : IF type$ = "drums" THEN waveforms$(count%) = "BDPiloMute" ELSE waveforms$(count%) = "Trumpet"
  WHEN 10 : IF type$ = "drums" THEN waveforms$(count%) = "CongaHi" ELSE waveforms$(count%) = "EngHornGb"
  WHEN 11 : IF type$ = "drums" THEN waveforms$(count%) = "CongaMid" ELSE waveforms$(count%) = "ClarinetBb"
  WHEN 12 : IF type$ = "drums" THEN waveforms$(count%) = "CongaSmCl" ELSE waveforms$(count%) = "ClarVibEb"
  WHEN 14 : IF type$ = "drums" THEN waveforms$(count%) = "ElecTom1" ELSE waveforms$(count%) = "BassoonEb"
  WHEN 16 : IF type$ = "drums" THEN waveforms$(count%) = "RotoTomRev" ELSE waveforms$(count%) = "FlugelHnEb"
  WHEN 15 : IF type$ = "drums" THEN waveforms$(count%) = "SimmonsBD1" ELSE waveforms$(count%) = "CornetEb"
  WHEN 13 : IF type$ = "drums" THEN waveforms$(count%) = "Snare" ELSE waveforms$(count%) = "TubaGb"
  WHEN 6 : IF type$ = "drums" THEN waveforms$(count%) = "SnareEcho" ELSE waveforms$(count%) = "BassBowAb"
  WHEN 17 : IF type$ = "drums" THEN waveforms$(count%) = "SynTom" ELSE waveforms$(count%) = "JapFlute"
  WHEN 18 : IF type$ = "drums" THEN waveforms$(count%) = "TablaHi" ELSE waveforms$(count%) = "EnsWodAb45"
  WHEN 19 : IF type$ = "drums" THEN waveforms$(count%) = "Tomtom1" ELSE waveforms$(count%) = "Bass"
 ENDCASE
NEXT
:
PROCwindow(20,72,83,25)
   VDU 14
   PRINT'" Current assignations are now "
   PRINT " (press Ctrl-Shift to scroll down) "
   FOR count% = 1 TO numparts%
    IF waveforms$(count%) <> "" THEN
     PRINT'"  voice ";count%;
     IF insts$(count%,0)<> "" THEN PRINT " (";insts$(count%,0);")";
     PRINT " - ";waveforms$(count%)
    ENDIF
   NEXT
   VDU 15
   PRINT'" Do you want to keep these, reassign,"
   PRINT " use WaveSynth-Beep defaults, "
   PRINT " randomly assign sustaining/dry instruments/drums "
   PRINT " to all staves, or assign in groups "
   PRINT " (K/R/W/S/D/M/G) "

   CASE GET$ OF
    WHEN "R","r" : defaultvoices$ = "n" : PROCassignvoices : PROCdisplay
    WHEN "W","w" : defaultvoices$ = "y" : PROCassignvoices : PROCdisplay
    WHEN "K","k" : defaultvoices$ = "n" : PROCdisplay
    WHEN "S","s" : defaultvoices$ = "n" : type$ = "sustaining" : PROCrandomassign : PROCdisplay
    WHEN "M","m" : defaultvoices$ = "n" : type$ = "drums" : PROCrandomassign : PROCdisplay
    WHEN "D","d" : defaultvoices$ = "n" : PROCrandomdry : PROCdisplay
    WHEN "G","g" : defaultvoices$ = "n" : PROCgroupassign : PROCdisplay
   ENDCASE

:
ENDPROC
:
REM************************************************************************8
:
DEF PROCrandomdry
:
CLS
PRINT'" Group A = 'ch' sounds "
PRINT " Group B = 'donk' sounds "
PRINT " Group C = pizz sounds "
PRINT'" Select a group or to mix A+B press D, to mix A+C press E "
PRINT " to mix B+C press F, or to mix all three press G "
CASE GET$ OF
 WHEN "A","a" : choice$ = "A"
 WHEN "B","b" : choice$ = "B"
 WHEN "C","c" : choice$ = "C"
 WHEN "D","d" : choice$ = "D"
 WHEN "E","e" : choice$ = "E"
 WHEN "F","f" : choice$ = "F"
 OTHERWISE choice$ = "G"
ENDCASE
:
INPUT'" between voice (for first press 0) "first%
IF first% = 0 THEN first% = 1
INPUT'" and voice (for last press 0) "last%
IF last% = 0 THEN last% = numparts%
:
FOR count% = first% TO last%
waveforms$(count%) = "empty"
NEXT
:
FOR count% = first% TO last%
:
REPEAT
 x% = RND(19)
 :
 CASE x% OF
  WHEN 1 : IF choice$ = "A" OR choice$ = "D" OR choice$ = "E" OR choice$ = "G" THEN waveforms$(count%) = "GuiroFast"
  WHEN 2 : IF choice$ = "A" OR choice$ = "D" OR choice$ = "E" OR choice$ = "G" THEN waveforms$(count%) = "Cachichi1"
  WHEN 3 : IF choice$ = "A" OR choice$ = "D" OR choice$ = "E" OR choice$ = "G" THEN waveforms$(count%) = "Cabasa"
  WHEN 4 : IF choice$ = "A" OR choice$ = "D" OR choice$ = "E" OR choice$ = "G" THEN waveforms$(count%) = "HiHat"
  WHEN 5 : IF choice$ = "A" OR choice$ = "D" OR choice$ = "E" OR choice$ = "G" THEN waveforms$(count%) = "HiHatFoot"
  WHEN 7 : IF choice$ = "B" OR choice$ = "D" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "TablaHi"
  WHEN 8 : IF choice$ = "B" OR choice$ = "D" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "Clave"
  WHEN 9 : IF choice$ = "B" OR choice$ = "D" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "AgogoWood"
  WHEN 10 : IF choice$ = "B" OR choice$ = "D" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "CongaHi"
  WHEN 11 : IF choice$ = "B" OR choice$ = "D" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "CowBell"
  WHEN 12 : IF choice$ = "B" OR choice$ = "D" OR choice$ = "F" OR choice$ = "G" waveforms$(count%) = "AgogoAfric"
  WHEN 14 : IF choice$ = "B" OR choice$ = "D" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "Vibe"
  WHEN 16 : IF choice$ = "B" OR choice$ = "D" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "Xylophone"
  WHEN 15 : IF choice$ = "C" OR choice$ = "E" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "AcouBass"
  WHEN 13 : IF choice$ = "C" OR choice$ = "E" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "AcuBassAb1"
  WHEN 6 : IF choice$ = "C" OR choice$ = "E" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "AcGuitar1"
  WHEN 17 : IF choice$ = "C" OR choice$ = "E" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "Bass"
  WHEN 18 : IF choice$ = "C" OR choice$ = "E" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "AcouGtr2B"
  WHEN 19 : IF choice$ = "C" OR choice$ = "E" OR choice$ = "F" OR choice$ = "G" THEN waveforms$(count%) = "GtrDobroB"
  REM another possibility is Harp1
 ENDCASE
:
UNTIL waveforms$(count%) <> "empty"
:
NEXT
:
PROCwindow(20,72,83,25)
   VDU 14
   PRINT'" Current assignations are now "
   PRINT " (press Ctrl-Shift to scroll down) "
   FOR count% = 1 TO numparts%
    IF waveforms$(count%) <> "" THEN
     PRINT'"  voice ";count%;
     IF insts$(count%,0)<> "" THEN PRINT " (";insts$(count%,0);")";
     PRINT " - ";waveforms$(count%)
    ENDIF
   NEXT
   VDU 15
   PRINT'" Do you want to keep these, reassign,"
   PRINT " use WaveSynth-Beep defaults, "
   PRINT " randomly assign sustaining/dry instruments/drums "
   PRINT " to all staves, or assign in groups "
   PRINT " (K/R/W/S/D/M/G) "

   CASE GET$ OF
    WHEN "R","r" : defaultvoices$ = "n" : PROCassignvoices : PROCdisplay
    WHEN "W","w" : defaultvoices$ = "y" : PROCassignvoices : PROCdisplay
    WHEN "K","k" : defaultvoices$ = "n" : PROCdisplay
    WHEN "S","s" : defaultvoices$ = "n" : type$ = "sustaining" : PROCrandomassign : PROCdisplay
    WHEN "M","m" : defaultvoices$ = "n" : type$ = "drums" : PROCrandomassign : PROCdisplay
    WHEN "D","d" : defaultvoices$ = "n" : PROCrandomdry : PROCdisplay
    WHEN "G","g" : defaultvoices$ = "n" : PROCgroupassign : PROCdisplay
   ENDCASE

:
ENDPROC

:
REM***********************************************************************************
:
DEF PROCgroupassign
:
CLS
PRINT'" Groups of voices ranging downwards are to "
PRINT " take the waveform of the first in the group "
INPUT " in batches of how many voices "gap%
INPUT'" To apply between voice "low%
INPUT " and voice "high%
:
FOR count% = 1 TO numparts%
 :
 IF count% >= low% AND count% <= high% THEN
  :
  x% = 0
  REPEAT
  :
   IF count% > (low%+(gap%*x%)) AND count% < (low%+(gap%*(x%+1))) THEN
    number% = low%+(gap%*x%)
    waveforms$(count%) = waveforms$(number%)
   ENDIF
  :
  x% = x%+1
  UNTIL (low%+(gap%*x%)) > high%
  :
 ENDIF
 :
NEXT
:
PROCwindow(20,72,83,25)
   VDU 14
   PRINT'" Current assignations are now "
   PRINT " (press Ctrl-Shift to scroll down) "
   FOR count% = 1 TO numparts%
    IF waveforms$(count%) <> "" THEN
     PRINT'"  voice ";count%;
     IF insts$(count%,0)<> "" THEN PRINT " (";insts$(count%,0);")";
     PRINT " - ";waveforms$(count%)
    ENDIF
   NEXT
   VDU 15
   PRINT'" Do you want to keep these, reassign,"
   PRINT " use WaveSynth-Beep defaults, "
   PRINT " randomly assign sustaining/dry instruments "
   PRINT " to all staves, or assign in groups "
   PRINT " (K/R/W/S/D/G) "

   CASE GET$ OF
    WHEN "R","r" : defaultvoices$ = "n" : PROCassignvoices : PROCdisplay
    WHEN "W","w" : defaultvoices$ = "y" : PROCassignvoices : PROCdisplay
    WHEN "K","k" : defaultvoices$ = "n" : PROCdisplay
    WHEN "S","s" : defaultvoices$ = "n" : PROCrandomassign : PROCdisplay
    WHEN "D","d" : defaultvoices$ = "n" : PROCrandomdry : PROCdisplay
    WHEN "G","g" : defaultvoices$ = "n" : PROCgroupassign : PROCdisplay
   ENDCASE
 :
ENDPROC
:
REM***********************************************************************************

:
DEF PROCpitchstring4
:
CLS
INPUT'" How many attacks "many%
 PRINT'" the first note is ";
COLOUR 3
 CASE GET$ OF
  WHEN "c" : note1% = 0 : PRINT "C"
  WHEN "d" : note1% = 1 : PRINT "D"
  WHEN "e" : note1% = 2 : PRINT "E"
  WHEN "f" : note1% = 3 : PRINT "F"
  WHEN "g" : note1% = 4 : PRINT "G"
  WHEN "a" : note1% = 5 : PRINT "A"
  WHEN "b" : note1% = 6 : PRINT "B"
 ENDCASE
COLOUR 0
PRINT " accidental ";
COLOUR 3
 CASE GET$ OF
  WHEN "1" : accid1% = 1 : PRINT "  flat"
  WHEN "2" : accid1% = 2 : PRINT "  3/8 flat"
  WHEN "3" : accid1% = 3 : PRINT "  1/4 flat"
  WHEN "4" : accid1% = 4 : PRINT "  1/8 flat"
  WHEN "5" : accid1% = 5 : PRINT "  natural"
  WHEN "6" : accid1% = 6 : PRINT "  1/8 sharp"
  WHEN "7" : accid1% = 7 : PRINT "  1/4 sharp"
  WHEN "8" : accid1% = 8 : PRINT "  3/8 sharp"
  WHEN "9" : accid1% = 9 : PRINT "  sharp"
 ENDCASE
COLOUR 0
PRINT " octave ";
COLOUR 3
 CASE GET$ OF
  WHEN "1" : octave1% = 1 : PRINT "  octave 1"
  WHEN "2" : octave1% = 2 : PRINT "  octave 2"
  WHEN "3" : octave1% = 3 : PRINT "  octave 3"
  WHEN "4" : octave1% = 4 : PRINT "  octave 4"
  WHEN "5" : octave1% = 5 : PRINT "  octave 5"
  WHEN "6" : octave1% = 6 : PRINT "  octave 6"
  WHEN "7" : octave1% = 7 : PRINT "  octave 7"
  WHEN "8" : octave1% = 8 : PRINT "  octave 8"
 ENDCASE
COLOUR 0
 PRINT'" and the second note is ";
COLOUR 3
 CASE GET$ OF
  WHEN "c" : note2% = 0 : PRINT "C"
  WHEN "d" : note2% = 1 : PRINT "D"
  WHEN "e" : note2% = 2 : PRINT "E"
  WHEN "f" : note2% = 3 : PRINT "F"
  WHEN "g" : note2% = 4 : PRINT "G"
  WHEN "a" : note2% = 5 : PRINT "A"
  WHEN "b" : note2% = 6 : PRINT "B"
 ENDCASE
COLOUR 0
PRINT " accidental ";
COLOUR 3
 CASE GET$ OF
  WHEN "1" : accid2% = 1 : PRINT "  flat"
  WHEN "2" : accid2% = 2 : PRINT "  3/8 flat"
  WHEN "3" : accid2% = 3 : PRINT "  1/4 flat"
  WHEN "4" : accid2% = 4 : PRINT "  1/8 flat"
  WHEN "5" : accid2% = 5 : PRINT "  natural"
  WHEN "6" : accid2% = 6 : PRINT "  1/8 sharp"
  WHEN "7" : accid2% = 7 : PRINT "  1/4 sharp"
  WHEN "8" : accid2% = 8 : PRINT "  3/8 sharp"
  WHEN "9" : accid2% = 9 : PRINT "  sharp"
 ENDCASE
COLOUR 0
PRINT " octave ";
COLOUR 3
 CASE GET$ OF
  WHEN "1" : octave2% = 1 : PRINT "  octave 1"
  WHEN "2" : octave2% = 2 : PRINT "  octave 2"
  WHEN "3" : octave2% = 3 : PRINT "  octave 3"
  WHEN "4" : octave2% = 4 : PRINT "  octave 4"
  WHEN "5" : octave2% = 5 : PRINT "  octave 5"
  WHEN "6" : octave2% = 6 : PRINT "  octave 6"
  WHEN "7" : octave2% = 7 : PRINT "  octave 7"
  WHEN "8" : octave2% = 8 : PRINT "  octave 8"
 ENDCASE
COLOUR 0
tick% = 1
FOR count% = 1 TO many%
IF tick% = 1 THEN
pitches%(count%-1) = (note1%*100)+(accid1%*10)+octave1%
ELSE
pitches%(count%-1) = (note2%*100)+(accid2%*10)+octave2%
ENDIF
IF tick% = 1 THEN tick% = 2 ELSE tick% = 1
NEXT
:
numpitches% = many%
PROCinsertpitches
:
ENDPROC
:
REM*********************************************************************************
:
DEF PROCcopyonenote
 :
 repeatposit$ = "n"
 IF distort$ = "OFF" THEN dothis$ = "YES"
 IF distort$ = "ON" THEN
  IF distortpara$ = "attacks" THEN dothis$ = "YES" ELSE dothis$ = "NO"
 ENDIF
  copymove$ = "C" : savevoice$ = "N" : justone$ = "y"
 :
PROCcopy2
:
justone$ = "n"
  :
ENDPROC
:
REM***********************************************************************************
:
DEF PROCcopygroupofnotes
:
 repeatposit$ = "n"
 IF distort$ = "OFF" THEN dothis$ = "YES"
 IF distort$ = "ON" THEN
  IF distortpara$ = "attacks" THEN dothis$ = "YES" ELSE dothis$ = "NO"
 ENDIF
:
copymove$ = "C" : savevoice$ = "N" : justone$ = "n"
:
PROCcopy2
:
ENDPROC
:
REM*************************************************************************************
:
DEF PROCcopydownwards
:
 repeatposit$ = "n"
 IF distort$ = "OFF" THEN dothis$ = "YES"
 IF distort$ = "ON" THEN
  IF distortpara$ = "attacks" THEN dothis$ = "YES" ELSE dothis$ = "NO"
 ENDIF
  copymove$ = "C" : savevoice$ = "N" : justone$ = "y"
 :
 voice% = displayvoices%(startv%)
 voice% = voice%-1
 :
 along% = copydownwards%
 :
 along%-=1
 copystartbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  copystartbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  holdbar% = copystartbar%
  holdbeat% = copystartbeat%
 :
 copyendbar% = copystartbar%
 copyendbeat% = copystartbeat%
 :
 value% = (copystartbar%*10^3)+copystartbeat%
 IF value% <= array%(0,0,voice%)DIV10^3 THEN
  startatcell% = 0
 ELSE
 PROCsearch(value%)
 startatcell% = startcell%
 ENDIF
 IF copyendbar% = 0 THEN
 endatcell% = numusedcells%(voice%) - 1
 ELSE
 value% = (copyendbar%*10^3)+copyendbeat%
 IF value% >= array%(numusedcells%(voice%)-1,0,voice%)DIV10^3 THEN
  endatcell% = numusedcells%(voice%) - 1
 ELSE
 PROCsearch(value%)
 IF shunt$ = "N" THEN endatcell% = startcell% ELSE endatcell% = startcell% - 1
 ENDIF
 ENDIF
 :
 manyattacks% = endatcell% - startatcell% + 1
 REM create 'gap' between beat-of-bar and first actual attack
 carrybars% = (array%(startatcell%,0,voice%)DIV10^6)-copystartbar%
 carrybeats% = ((array%(startatcell%,0,voice%)DIV10^3)MOD10^3)-copystartbeat%
 attacks1%(0) = (carrybars%*960)+carrybeats%
 :
 IF copymove$ = "C" OR copymove$ = "M" THEN
 FOR count% = 0 TO (manyattacks%-1)
  IF count% > 0 THEN
   carrybars% = (array%(startatcell%+count%,0,voice%)DIV10^6)-(array%(startatcell%+count%-1,0,voice%)DIV10^6)
   carrybeats% = ((array%(startatcell%+count%,0,voice%)DIV10^3)MOD10^3)-((array%(startatcell%+count%-1,0,voice%)DIV10^3)MOD10^3)
   attacks1%(count%) = attacks1%(count%-1) + ((carrybars%*960)+carrybeats%)
  ENDIF
 :
  pitches%(count%) = array%(startatcell%+count%,0,voice%)MOD10^3
  dur% = (array%(startatcell%+count%,1,voice%)DIV10)MOD10^3
    brrr% = array%(startatcell%+count%,0,voice%)DIV10^6 : PROCreconvertdur
    durations%(count%) = dur%
  amplitudes%(count%) = (array%(startatcell%+count%,1,voice%))MOD10
  envelopes%(count%) = (array%(startatcell%+count%,2,voice%))DIV10^2
  glissandos%(count%) = array%(startatcell%+count%,1,voice%)DIV10^4
  inflections%(count%) = array%(startatcell%+count%,2,voice%)MOD10^2
 NEXT
 ELSE PROCextract
 ENDIF
 :
 IF copymove$ = "M" THEN
 numnotes% = manyattacks% : startcell% = startatcell%
 FOR count% = startcell% TO (startcell%+(numnotes%-1))
 FOR counter% = 0 TO 1
  barno% = (array%(count%,0,voice%)DIV10^6)-counter%
 beatnum% = ((array%(count%,0,voice%)DIV10^3)MOD10^3)
 :
  group1start% = (disarray%(barno%,0,voice%)DIV10^7)*beatfactor%
  group1end% = group1start% + (((disarray%(barno%,0,voice%)DIV10^5)MOD10^2)*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group1start% AND beatnum%+(960*counter%) <= group1end% THEN
  disarray%(barno%,0,voice%) = disarray%(barno%,0,voice%)MOD10^3
 ENDIF
 :
 group2start% = ((disarray%(barno%,0,voice%)DIV10)MOD10^2)*beatfactor%
 group2end% = group2start%+((((disarray%(barno%,0,voice%)MOD10)*10)+(disarray%(barno%,1,voice%)DIV10^8))*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group2start% AND beatnum%+(960*counter%) <= group2end% THEN
  disarray%(barno%,0,voice%) = (disarray%(barno%,0,voice%)DIV10^3)*10^3
  disarray%(barno%,1,voice%) = disarray%(barno%,1,voice%)MOD10^6
 ENDIF
 group3start%=((disarray%(barno%,1,voice%)DIV10^4)MOD10^2)*beatfactor%
 group3end% = group3start% + (((disarray%(barno%,1,voice%)MOD10^4)DIV10^2)*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group3start% AND beatnum%+(960*counter%) <= group3end% THEN
  disarray%(barno%,1,voice%) = (disarray%(barno%,1,voice%)DIV10^6)*10^6
 ENDIF
 group4start% = (disarray%(barno%,2,voice%)DIV10^7)*beatfactor%
 group4end% = group4start%+(((disarray%(barno%,2,voice%)DIV10^5)MOD10^2)*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group4start% AND beatnum%+(960*counter%) <= group4end% THEN
  disarray%(barno%,2,voice%) =  disarray%(barno%,2,voice%)MOD10^3
 ENDIF
 group5start% = ((disarray%(barno%,2,voice%)MOD10^3)DIV10)*beatfactor%
 group5end% = group5start%+((((disarray%(barno%,2,voice%)MOD10)*10)+(disarray%(barno%,3,voice%)DIV10^8))*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group5start% AND beatnum%+(960*counter%) <= group5end% THEN
 disarray%(barno%,2,voice%) = (disarray%(barno%,2,voice%)DIV10^3)*10^3
 disarray%(barno%,3,voice%) = disarray%(barno%,3,voice%)MOD10^6
 ENDIF
 group6start% = ((disarray%(barno%,3,voice%)DIV10^4)MOD10^2)*beatfactor%
 group6end% = group6start% + (((disarray%(barno%,3,voice%)DIV10^2)MOD10^2)*beatfactor%)-1
 IF beatnum%+(960*counter%) >= group6start% AND beatnum%+(960*counter%) <= group6end% THEN
 disarray%(barno%,3,voice%)=(disarray%(barno%,3,voice%)DIV10^6)*10^6
 ENDIF

 NEXT
 :
 NEXT
 PROCshuntleft(startcell%,numnotes%)
 ENDIF
 :
 numpitches% = manyattacks% : method$ = "raw" : copyit$ = "ON" : copydownwards$ = "y"
 :
 PROCinsertattacks
 :
 justone$ = "n" : copydownwards$ = "n"
 ENDPROC
 :
 REM****************************************************************
 :
 DEF PROCdeleteone
 :
  CASE deleteone$ OF
   WHEN "top" :
  voice% = 1
  voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
   WHEN "middle" :
  voice% = 2
  voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  WHEN "bottom" :
  voice% = 3
  voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  ENDCASE
  :
  numnotes% = 1
  :
  incre$ = INKEY$(100)
   IF incre$ <> "" THEN
    CASE incre$ OF
     WHEN "!" : along% = 1
     WHEN """" : along% = 2
     WHEN "�" : along% = 3
     WHEN "$" : along% = 4
     WHEN "%" : along% = 5
     WHEN "^" : along% = 6
     WHEN "&" : along% = 7
     WHEN "*" : along% = 8
     WHEN "(" : along% = 9
     WHEN ")" : along% = 10
    ENDCASE
   ELSE along% = 1
   ENDIF
  :
  IF addten$ = "y" THEN along% +=10
  IF addten$ = "twenty" THEN along% +=20
  :
  along%-=1
  copystartbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  copystartbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
  beats% = copystartbeat%
  PROCalterbeats
  start% = (copystartbar%*(10^3))+beats%
  PROCsearch(start%)
  PROCshuntleft(startcell%,numnotes%)
  :
  deleteone$ = "none"
  ENDPROC
:
REM**********************************************************************
:
DEF PROCpitchstring5
:
IF easiermenus$ = "n" THEN PROCwindow(20,65,60,55) ELSE PROCwindow(20,65,60,42)
PRINT'" This function returns a string"
PRINT" of pitches which recycles an"
PRINT" ascending chromatic scale,"
PRINT" useful for subsequently"
PRINT" extracting certain pitches"
INPUT'" How many semitones in the scale "numsemis%
INPUT'" How many pitches in the string "numpitches%
counter% = 0
:
FOR count% = 0 TO numpitches%-1
counter% += 1
CASE counter% OF
 WHEN 1 : pitches%(count%) = 54
 WHEN 2 : pitches%(count%) = 94
 WHEN 3 : pitches%(count%) = 154
 WHEN 4 : pitches%(count%) = 214
 WHEN 5 : pitches%(count%) = 254
 WHEN 6 : pitches%(count%) = 354
 WHEN 7 : pitches%(count%) = 394
 WHEN 8 : pitches%(count%) = 454
WHEN 9 : pitches%(count%) = 514
 WHEN 10 : pitches%(count%) = 554
 WHEN 11 : pitches%(count%) = 614
 WHEN 12 : pitches%(count%) = 654
ENDCASE
:
IF counter% = numsemis% THEN counter% = 0
:
NEXT
:
PROCinsertpitches
ENDPROC
:
******************************************
:
DEF PROCdurationsbetween
:
 IF numdurations% = 111 THEN mode$ = "legato"
 IF numdurations% = 222 THEN mode$ = "mezzostacc"
 PROCwindow(20,69,60,55)
 CLS
 :
 IF screenvoices$ = "n" THEN
   INPUT' " Which voice "voice%
   IF voice% = 0 THEN PROCpressenter
   ELSE
   PRINT'" Which screen voice "
   CASE GET$ OF
    WHEN "1" : voice% = 1
    WHEN "2" : voice% = 2
    WHEN "3" : voice% = 3
    OTHERWISE PROCpressenter
   ENDCASE
  ENDIF
  IF screenvoices$ = "y" AND voice% > 0 THEN voice% = displayvoices%(startv%+voice%-1)
  voice% -= 1
  IF voice% >= 0 THEN samevoice% = voice%
  IF voice% = -1 THEN voice% = samevoice%
 :
 INPUT'" How many gaps to be filled "numdurations%
 INPUT'" starting at note number "note%
 IF note% = 0 THEN note% = 1
 :
 PROCnewnotereception(voice%,startbar%,0,0,0,0,0,0,0)
 CASE option% OF
  WHEN 1 : startcell% = 0
  WHEN 2 : startcell% = numusedcells%(voice%)
   WHEN 3 : startcell% = 0
  WHEN 4 : start% = firstbar%*10^3 : PROCsearch(start%)
 ENDCASE
 silly% = startcell%+note%-1
 :
 FOR count% = 0 TO numdurations%-1
  beatdiff% = ((array%(silly%+1+count%,0,voice%)DIV10^3)MOD10^3)-((array%(silly%+count%,0,voice%)DIV10^3)MOD10^3)
  beatdiff%+=(((array%(silly%+1+count%,0,voice%)DIV10^6)-(array%(silly%+count%,0,voice%)DIV10^6))*960)
  CASE mode$ OF
   WHEN "legato" :
   durations%(count%+1) = beatdiff%
   OTHERWISE
  durations%(count%+1) = beatdiff%/2
   ENDCASE
 :
  NEXT
 :
 along% = note%-1
 copystartbar% = array%(holdstartcell%(voice%)+along%,0,voice%)DIV10^6
  copystartbeat% = (array%(holdstartcell%(voice%)+along%,0,voice%)MOD10^6)DIV10^3
beats% = copystartbeat%
PROCalterbeats
startat% = (copystartbar%*(10^3))+beats%
 :
 PROCsearch(startat%)
 shunt$ = "N"
 :
 FOR count% = startcell% TO (startcell%+(numdurations%-1))
 PROCcellfill(count%,voice%,999,999,999,9,999,durations%(count%-startcell%+1),99,99)
 NEXT
 :
 PROCdisplay
 :
 ENDPROC
 :
REM************************************************************************88
:
DEF PROCshortmove
:
ON : PROCwindow(20,69,60,55)
 CLS
 repeatposit$ = "n"
 IF distort$ = "OFF" THEN dothis$ = "YES"
 IF distort$ = "ON" THEN
  IF distortpara$ = "attacks" THEN dothis$ = "YES" ELSE dothis$ = "NO"
 ENDIF
:
 IF dothis$ = "YES" THEN
 copymove$ = "M" : savevoice$ = "N" : justone$ = "n"
  ELSE copymove$ = "C"
 ENDIF
:
PROCcopy2
IF quickextract$ = "y" THEN quickextract$ = "n"
:
ENDPROC
:
REM***********************************************************************8
:
DEF PROCshortmoveone
:
ON : PROCwindow(20,69,60,55)
 CLS
 repeatposit$ = "n"
 IF distort$ = "OFF" THEN dothis$ = "YES"
 IF distort$ = "ON" THEN
  IF distortpara$ = "attacks" THEN dothis$ = "YES" ELSE dothis$ = "NO"
 ENDIF
:
 IF dothis$ = "YES" THEN
 copymove$ = "M" : savevoice$ = "N" : justone$ = "y"
  ELSE copymove$ = "C"
 ENDIF
:
PROCcopy2
IF quickextract$ = "y" THEN quickextract$ = "n"
:
ENDPROC
:
REM************************************************************************
:
DEF PROCcopysuccessively
:
IF succfirsttime$ = "y" THEN
INPUT'" Which voice "voice%
IF voice% = 0 THEN PROCpressenter
fromvoice% = voice%
succfirsttime$ = "n"
succcounter% = 0
ELSE succcounter% += 1
ENDIF
:
IF succcounter% > 0 THEN
:
fromvoice% += 1 : voice% = fromvoice%
PRINT' " That's voice ";voice%;"?"
PRINT' " (0 = yes/C = cancel successive copying) "
CASE GET$ OF
 WHEN "C","c" :
  copysuccessively$ = "n" : succfirsttime$ = "y" : PROCdisplay
 OTHERWISE
ENDCASE
:
ENDIF
:
ENDPROC
:
REM***************************************************************************
:
DEF PROCpressenter
:
 COLOUR 3
 incre$ = INKEY$(50)
 IF incre$ = "" THEN
  IF screenvoices$ = "y" THEN
   voice% = 1 : PRINT ' voice%
  ELSE
   voice% = displayvoices%(startv%) : PRINT ' voice%
  ENDIF
 ELSE
  incre$ = INKEY$(50)
  IF screenvoices$ = "y" THEN
   IF incre$ = "" THEN voice% = 2 ELSE voice% = 3
   PRINT ' voice%
  ELSE
   IF incre$ = "" THEN voice% = displayvoices%(startv%+1) ELSE voice% = displayvoices%(startv%+2)
   PRINT ' voice%
  ENDIF
 ENDIF
 COLOUR 0
:
ENDPROC
:
REM***************************************************************************
:
DEF PROCfornexttime
:
IF housekeepingdimmed$ = "n" THEN
DIM lastfilename$(9)
ENDIF
*Dir SDFS::RISCOSpi.$.CAC.Files
 thisfilename$ = "housekeeping2"
channel = OPENOUT thisfilename$
  FOR count% = 1 TO 9
   PRINT#channel, lastfilename$(count%)
  NEXT
 CLOSE#channel
*NoDir
:
ENDPROC
:
REM****************************************************************************
:
DEF PROChousekeeping
:
IF housekeepingdimmed$ = "n" THEN
DIM lastfilename$(9) : housekeepingdimmed$ = "y"
ENDIF
*Dir SDFS::RISCOSpi.$.CAC.Files
thisfilename$ = "housekeeping2"
channel = OPENIN thisfilename$
REPEAT
 FOR count% = 1 TO 9
  INPUT#channel, lastfilename$(count%)
 NEXT
UNTIL EOF#channel
CLOSE#channel
*NoDir
:
ENDPROC
:
REM*****************************************************************************
:
DEF PROCshuntlastfilename
:
FOR count% = 9 TO 2 STEP -1
 lastfilename$(count%) = lastfilename$(count%-1)
NEXT
lastfilename$(1) = filename$
:
ENDPROC
:
REM*****************************************************************************
:
DEF PROCspecialshunt
:
FOR count% = theone% TO 2 STEP -1
 lastfilename$(count%) = lastfilename$(count%-1)
NEXT
lastfilename$(1) = filename$
:
ENDPROC
:
REM******************************************************************************
:
DEF PROCroguenotes
:
FOR count% = 0 TO numparts%-1
array%(numusedcells%(count%),0,count%) = 0
NEXT
:
PROCdisplay
:
ENDPROC
:
REM*******************************************************************
:
DEF PROCnotenumberfreq
:
CASE nosevery% OF
 WHEN 1 :
  IF howmany% >= startnos% THEN printnumber$ = "y" ELSE printnumber$ = "n"
 WHEN 2 :
  howmany = howmany%/2
  howmany = (howmany * 10) MOD 10
  IF howmany = 5 THEN printnumber$ = "n" ELSE printnumber$ = "y"
  IF howmany% < startnos% THEN printnumber$ = "n"
 WHEN 4 :
  howmany = howmany%/4
  howmany = (howmany * 10) MOD 10
  IF howmany = 2 OR howmany = 5 OR howmany = 7 THEN printnumber$ = "n" ELSE printnumber$ = "y"
  IF howmany% < startnos% THEN printnumber$ = "n"
 WHEN 10 :
  IF howmany% MOD 10 = 0 THEN printnumber$ = "y" ELSE printnumber$ = "n"
  IF howmany% < startnos% THEN printnumber$ = "n"
ENDCASE
:
ENDPROC
:
REM**************************************************************************
:
DEF PROCnotenumbersep
old% = current%
current% = hposn%-100
gap% = current%-old%
IF old% <> 0 AND howmany% > 1 THEN
 IF gap% < 50 THEN lowernumber% += 20 ELSE lowernumber% = 0
 IF (hposn%-100) - firsttrack% > 50 THEN
  lowernumber% = 0
  firsttrack% = hposn%-100
 ENDIF
ENDIF
ENDPROC
:
REM****************************************************************************
:
DEF PROCpitchstring6
:
CLS
PRINT'" How many semitones high is the "
INPUT " vertical space (0 = previous) "height
IF height = 0 THEN
 height = previousheight
 COLOUR 3
 PRINT' previousheight
 COLOUR 0
ENDIF
PRINT'" and this is to be divided into "
INPUT " how many steps "steps
IF steps = 0 THEN
 steps = previoussteps
 COLOUR 3
 PRINT' previoussteps
 COLOUR 0
ENDIF
:
each = height/(steps-1)
result = 0
FOR count% = 1 TO (steps-1)
result += each
IF ((result*10)MOD10) <= 5 add$ = "n" ELSE add$ = "y"
result% = result DIV 1
IF add$ = "y" result% += 1
:
oct% = 1
IF result% > 11 THEN
REPEAT
 result% -= 12
 oct% += 1
UNTIL result% < 12
ENDIF
:
CASE result% OF
 WHEN 0 : pitch% = 050
 WHEN 1 : pitch% = 090
 WHEN 2 : pitch% = 150
 WHEN 3 : pitch% = 210
 WHEN 4 : pitch% = 250
 WHEN 5 : pitch% = 350
 WHEN 6 : pitch% = 390
 WHEN 7 : pitch% = 450
 WHEN 8 : pitch% = 490
 WHEN 9 : pitch% = 550
 WHEN 10 : pitch% = 610
 WHEN 11 : pitch% = 650
ENDCASE
:
pitch% += oct%
pitches%(count%) = pitch%
pitches%(0) = 051
NEXT
numpitches% = steps
:
PRINT'" Contour upwards, downwards,"
PRINT " up-down, down-up (1/2/3/4) "
CASE GET$ OF
 WHEN "1" : previouscontour$ = "1"
 WHEN "2" : previouscontour$ = "2" : PROCcontourdown
 WHEN "3" : previouscontour$ = "3" : PROCcontourupdown
 WHEN "4" : previouscontour$ = "4" : PROCcontourdownup
 OTHERWISE
  CASE previouscontour$ OF
   WHEN "1" : COLOUR 3 : PRINT'" upwards " : COLOUR 0
   wait$ = INKEY$(50)
   WHEN "2" : PROCcontourdown : COLOUR 3 : PRINT' "downwards " : COLOUR 0
   wait$ = INKEY$(50)
   WHEN "3" : PROCcontourupdown : COLOUR 3 : PRINT'" up-down " : COLOUR 0
   wait$ = INKEY$(50)
   WHEN "4" : PROCcontourdownup : COLOUR 3 : PRINT' " down-up " : COLOUR 0
   wait$ = INKEY$(50)
  ENDCASE
ENDCASE
:
previousheight = height
previoussteps = steps
:
PROCinsertpitches
:
ENDPROC
:
REM************************************************************************8
:
DEF PROCcontourdown
:
FOR count% = 0 TO (numpitches%-1)
pitches1%(count%) = pitches%((numpitches%-1)-count%)
NEXT
FOR count% = 0 TO (numpitches%-1)
pitches%(count%) = pitches1%(count%)
NEXT
:
ENDPROC
:
REM***************************************************************************
:
DEF PROCcontourupdown
:
middle% = ((numpitches%+1)/2)-1
addnumber% = 1
minusnumber% = 0
swing$ = "add"
FOR count% = 0 TO (numpitches%-1)
IF swing$ = "subtract" THEN swing$ = "add" ELSE swing$ = "subtract"
:
IF swing$ = "add" THEN
pitches1%(middle%+addnumber%) = pitches%((numpitches%-1)-count%)
addnumber% += 1
ELSE
pitches1%(middle%-minusnumber%) = pitches%((numpitches%-1)-count%)
minusnumber% += 1
ENDIF
NEXT
:
FOR count% = 0 TO (numpitches%-1)
pitches%(count%) = pitches1%(count%)
NEXT
:
ENDPROC
:
REM******************************************************************************
:
DEF PROCcontourdownup
:
middle% = ((numpitches%+1)/2)-1
addnumber% = 1
minusnumber% = 0
swing$ = "add"
FOR count% = 0 TO (numpitches%-1)
IF swing$ = "subtract" THEN swing$ = "add" ELSE swing$ = "subtract"
:
IF swing$ = "add" THEN
pitches1%(middle%+addnumber%) = pitches%(count%)
addnumber% += 1
ELSE
pitches1%(middle%-minusnumber%) = pitches%(count%)
minusnumber% += 1
ENDIF
NEXT
:
FOR count% = 0 TO (numpitches%-1)
pitches%(count%) = pitches1%(count%)
NEXT
:
ENDPROC
:
REM**********************************************************************************
:
DEF PROCdisplayonlycontent
:
IF onlycontent$ = "n" THEN
displayvoices%() = displayvoices1%() : numvoices% = numvoices1%
ELSE
voicedone% = -1 : voicesdone% = 0 : displayvoices1%() = displayvoices%()
numvoices1% = numvoices%
FOR count% = 1 TO numvoices%
 FOR counter% = startbar% TO (startbar%+numbars%-1)
  voice% = displayvoices%(count%)-1
   addingnotes$ = "n"
   PROCnewnotereception(voice%,counter%,0,0,0,0,0,0,0)
   CASE option% OF
    WHEN 1 : startcell% = 0
    WHEN 2 : startcell% = numusedcells%(voice%)
    WHEN 3 : startcell% = 0
    WHEN 4 : PROCsearch(counter%*10^3)
   ENDCASE
   IF array%(startcell%,0,voice%) DIV10^6 > 0 THEN
    IF (array%(startcell%,0,voice%) DIV10^6) < (startbar%+numbars%) THEN
    IF voice% <> voicedone% THEN
    voicesdone% += 1 : displayvoices%(voicesdone%) = (voice%+1) : holddisplay%(voicesdone%) =  (voice%+1)
    voicedone% = voice%
    ENDIF
    ENDIF
   ENDIF
  NEXT
 NEXT
 :
numvoices% = voicesdone% : startv% = 1 : holdstart% = 1
:
ENDIF
:
PROCdisplay
:
ENDPROC
:
REM**********************************************************8
:
DEF PROCcontentonlylist
:
CLS
PRINT ""
voicedone% = -1
FOR count% = 1 TO numvoices%
 FOR counter% = startbar% TO (startbar%+numbars%-1)
  voice% = displayvoices%(count%)-1
  addingnotes$ = "n"
  PROCnewnotereception(voice%,counter%,0,0,0,0,0,0,0)
  CASE option% OF
   WHEN 1 : startcell% = 0
   WHEN 2 : startcell% = numusedcells%(voice%)
   WHEN 3 : startcell% = 0
   WHEN 4 : PROCsearch(counter%*10^3)
  ENDCASE
 IF array%(startcell%,0,voice%) DIV 10^6 > 0 THEN
  IF (array%(startcell%,0,voice%)) DIV 10^6 < (startbar%+numbars%) THEN
   IF voice% <> voicedone% THEN
    IF compress$ = "n" THEN
    PRINT ' voice%+1;". ";insts$(voice%+1,0)
    ELSE
    PRINT voice%+1;". ";insts$(voice%+1,0)
    ENDIF
    voicedone% = voice%
   ENDIF
  ENDIF
 ENDIF
 NEXT
NEXT
:
PRINT'" (press R to remove the list, press C to"
PRINT'"  compress/uncompress the list or press Q to"
PRINT'"  go to Quickdisplay without removing the list"
CASE GET$ OF
 WHEN "C","c" :
 IF compress$ = "y" THEN compress$ = "n" ELSE compress$ = "y"
 PROCcontentonlylist
 WHEN "Q","q" : quickdisplaywindow$ = "n" : PROCquickdisplay
 OTHERWISE PROCdisplay
ENDCASE
:
ENDPROC
:
REM*************************************************************
:
DEF PROCundoprepare
:
 manynotesX%=manynotes%
  numpartsX%=numparts%
  nobarsX% =nobars%
  startvX% =startv%
  startv1X% =startv1%
  numbarsX% =numbars%
  startbarX% =startbar%
  numvoicesX%=numvoices%
  factorX% =factor%
  beatfactorX%=beatfactor%
  beamsX% =beams%
  longbeatsupperX%= longbeatsupper%
  longbeatslowerX%=longbeatslower%
  tempoX%  =tempo%
  MMX%  =MM%
  noteheadX$=notehead$
  longscoreX$= longscore$
  barlinesX$ =barlines$
  stavesX$ =staves$
  beatsX$ =beats$
  amplitudesX$= amplitudes$
  namesX$ =names$
  accidentalsX$=accidentals$
  stemsX$=stems$
  xoptionX$= xoption$
  durationsX$=durations$
  envelopesX$ =envelopes$
  glissandosX$ =glissandos$
  numwavesX% =numwaves%
  manywavesX% =manywaves%
  barnosoftenX%= barnosoften%
 FOR c% = 0 TO (numparts%-1)
   numusedcellsX%(c%)=numusedcells%(c%)
 NEXT
 FOR e% = 0 TO (numparts%-1)
  FOR d% = 0 TO 2
   FOR c% = 0 TO manynotes%
     arrayX%(c%,d%,e%)=array%(c%,d%,e%)
   NEXT
  NEXT
 NEXT
 FOR c% = 0 TO numparts%
  FOR d% = 0 TO 2
    instsX$(c%,d%)=insts$(c%,d%)
  NEXT
 NEXT
 FOR c% = 0 TO nobars%
  FOR d% = 0 TO 3
   FOR e% = 0 TO (numparts%-1)
     disarrayX%(c%,d%,e%)= disarray%(c%,d%,e%)
   NEXT
  NEXT
 NEXT
 FOR c% = 0 TO numparts%
   longbeamposnX%(c%) =longbeamposn%(c%)
 NEXT
 FOR c% = 0 TO numparts%
   shortbeamposnX%(c%) =shortbeamposn%(c%)
 NEXT
 FOR c% = 0 TO numparts%
   shortampposX%(c%)=shortamppos%(c%)
 NEXT
 FOR c% = 0 TO numparts%
   longampposX%(c%) =longamppos%(c%)
 NEXT
 FOR c% = 0 TO (numparts%-1)
   longstemdirX$(c%)=longstemdir$(c%)
 NEXT
 FOR c% = 0 TO (numparts%-1)
   shortstemdirX$(c%)=shortstemdir$(c%)
 NEXT
 FOR c% = 0 TO numparts%
   waveformsX$(c%)=waveforms$(c%)
 NEXT
 FOR c% = 0 TO numvoices%
   displayvoicesX%(c%)=displayvoices%(c%)
 NEXT
 FOR c% = 0 TO 19
   wformsX$(c%)=wforms$(c%)
 NEXT
 FOR c% = 0 TO 8
  FOR d% = 0 TO 9
    lvdataX%(c%,d%)= lvdata%(c%,d%)
  NEXT
 NEXT
 FOR a% = 0 TO 47
    pitchsetX%(a%)=pitchset%(a%)
 NEXT
 FOR a% = 0 TO 47
    dursetX%(a%)=durset%(a%)
 NEXT
 FOR a% = 0 TO 47
    ampsetX%(a%) =ampset%(a%)
 NEXT
 FOR a% = 0 TO 47
    glisssetX%(a%)=glissset%(a%)
 NEXT
 FOR a% = 0 TO 47
    envsetX%(a%) =envset%(a%)
 NEXT
 FOR a% = 0 TO nobars%
    tempiX%(a%) =tempi%(a%)
 NEXT
 FOR a% = 0 TO nobars%
  FOR b% = 0 TO 1
    remarksX$(a%,b%)= remarks$(a%,b%)
  NEXT
 NEXT
:
ENDPROC
:
REM****************************************
:
DEF PROCundo
:
manynotes%=manynotes%
  numparts%=numpartsX%
  nobars% =nobarsX%
  startv% =startvX%
  startv1% =startv1X%
  numbars% =numbarsX%
  startbar% =startbarX%
  numvoices%=numvoicesX%
  factor% =factorX%
  beatfactor%=beatfactorX%
  beams% =beamsX%
  longbeatsupper%= longbeatsupperX%
  longbeatslower%=longbeatslowerX%
  tempo%  =tempoX%
  MM%  =MMX%
  notehead$=noteheadX$
  longscore$= longscoreX$
  barlines$ =barlinesX$
  staves$ =stavesX$
  beats$ =beatsX$
  amplitudes$= amplitudesX$
  names$ =namesX$
  accidentals$=accidentalsX$
  stems$=stemsX$
  xoption$= xoptionX$
  durations$=durationsX$
  envelopes$ =envelopesX$
  glissandos$ =glissandosX$
  numwaves% =numwavesX%
  manywaves% =manywavesX%
  barnosoften%= barnosoftenX%
 FOR c% = 0 TO (numparts%-1)
   numusedcells%(c%)=numusedcellsX%(c%)
 NEXT
 FOR e% = 0 TO (numparts%-1)
  FOR d% = 0 TO 2
   FOR c% = 0 TO manynotes%
     array%(c%,d%,e%)=arrayX%(c%,d%,e%)
   NEXT
  NEXT
 NEXT
 FOR c% = 0 TO numparts%
  FOR d% = 0 TO 2
    insts$(c%,d%)=instsX$(c%,d%)
  NEXT
 NEXT
 FOR c% = 0 TO nobars%
  FOR d% = 0 TO 3
   FOR e% = 0 TO (numparts%-1)
     disarray%(c%,d%,e%)= disarrayX%(c%,d%,e%)
   NEXT
  NEXT
 NEXT
 FOR c% = 0 TO numparts%
   longbeamposn%(c%) =longbeamposnX%(c%)
 NEXT
 FOR c% = 0 TO numparts%
   shortbeamposn%(c%) =shortbeamposnX%(c%)
 NEXT
 FOR c% = 0 TO numparts%
   shortamppos%(c%)=shortampposX%(c%)
 NEXT
 FOR c% = 0 TO numparts%
   longamppos%(c%) =longampposX%(c%)
 NEXT
 FOR c% = 0 TO (numparts%-1)
   longstemdir$(c%)=longstemdirX$(c%)
 NEXT
 FOR c% = 0 TO (numparts%-1)
   shortstemdir$(c%)=shortstemdirX$(c%)
 NEXT
 FOR c% = 0 TO numparts%
   waveforms$(c%)=waveformsX$(c%)
 NEXT
 FOR c% = 0 TO numvoices%
   displayvoices%(c%)=displayvoicesX%(c%)
 NEXT
 FOR c% = 0 TO 19
   wforms$(c%)=wformsX$(c%)
 NEXT
 FOR c% = 0 TO 8
  FOR d% = 0 TO 9
    lvdata%(c%,d%)= lvdataX%(c%,d%)
  NEXT
 NEXT
 FOR a% = 0 TO 47
    pitchset%(a%)=pitchsetX%(a%)
 NEXT
 FOR a% = 0 TO 47
    durset%(a%)=dursetX%(a%)
 NEXT
 FOR a% = 0 TO 47
    ampset%(a%) =ampsetX%(a%)
 NEXT
 FOR a% = 0 TO 47
    glissset%(a%)=glisssetX%(a%)
 NEXT
 FOR a% = 0 TO 47
    envset%(a%) =envsetX%(a%)
 NEXT
 FOR a% = 0 TO nobars%
    tempi%(a%) =tempiX%(a%)
 NEXT
 FOR a% = 0 TO nobars%
  FOR b% = 0 TO 1
    remarks$(a%,b%)= remarksX$(a%,b%)
  NEXT
 NEXT
:
PROCdisplay
:
ENDPROC
:
REM*********************************
:
DEF PROCtutorial
:
CLS
:
   PRINT ' " Bars and beats            B"
   PRINT ' " Handling of durations     D"
   PRINT ' " Exiting dialogue windows  E"
   PRINT ' " Quickly selecting voices  W"
   PRINT ' " Accel/rit                 A"
   CASE GET$ OF
    WHEN "D","d" : PROCwindow(10,71,72,20) : CLS
    PRINT  '" When a duration is input in bars/beats it is converted "
    PRINT  '" into 1/20ths of a second at the current tempo "
    PRINT  '" before being saved in the array. "
    PRINT  '" (This is because when sounds are played, their durations "
    PRINT  '" are given by BASIC to the OS as so many 1/20ths of a second). "
    PRINT' '" The Display procedure then reconverts back to bars/beats. "
    PRINT' '" Unavoidable floating point discrepencies occur during "
    PRINT  '" this conversion/reconversion process, which often lead to "
    PRINT  '" durations being displayed with different values to those "
    PRINT  '" initially input, especially in the case of very small values. "
    PRINT ''" (to return to program press any key)"
    CASE GET$ OF
     WHEN "R","r" : PROCdisplay
     OTHERWISE PROCdisplay
    ENDCASE
    :
    WHEN "E","e" : PROCwindow(10,71,72,20) : CLS
    PRINT  '" When no obvious key-presses are indicated, e.g. when you "
    PRINT  '" want to exit a dialogue window at any point etc., simply "
    PRINT  '" press <Esc> to return to the display. "
     CASE GET$ OF
      WHEN "R","r" : PROCdisplay
      OTHERWISE PROCdisplay
     ENDCASE
    :
    WHEN "W","w" : PROCwindow(10,71,72,20) : CLS
    PRINT  '" This is a keyboard shortcut to select a voice which "
    PRINT  '" is already displayed on the screen. "
    PRINT  '" Press <Enter> once to select the top voice displayed. "
    PRINT  '" Press <Enter> twice quickly to select the second voice "
    PRINT  '" selected. Press <Enter> three times quickly to select "
    PRINT  '" the bottom voice displayed. "
    CASE GET$ OF
     WHEN "R","r" : PROCdisplay
     OTHERWISE PROCdisplay
    ENDCASE
    :
    WHEN "A","a": PROCwindow(10,71,72,20) : CLS
    CASE GET$ OF
     WHEN "R","r" : PROCdisplay
     OTHERWISE PROCdisplay
    ENDCASE
     :
    WHEN "B","b": PROCwindow(10,71,82,10) : CLS
    PRINT  '" CAC invariably understands that a bar consists of 960 micro-beats, "
    PRINT  '" regardless of which file you create. This fine gradation allows "
    PRINT  '" you to position sounds effectively in continuous time, just as "
    PRINT  '" CAC allows you also to position sounds effectively in continuous "
    PRINT  '" pitch. "
    PRINT ''" When you initially create a new file, you can decide how the bar "
    PRINT  '" is to be subdivided into a particular 'time signature'. For example, "
    PRINT  '" in 4/4 each crotchet is a quarter of the bar, and thus 240 beats each."
    PRINT  '" When a passage will later be 'rhythmicized' to become musical notation "
    PRINT  '" each bar will consist of rhythms adding up to a 4/4 time signature."
    PRINT ''" The beats of a time signature are called macro-beats and their "
    PRINT  '" position can be displayed by pressing Display Menu/Add Beats (O/T). "
    CASE GET$ OF
     WHEN "R","r" : PROCdisplay
     OTHERWISE PROCdisplay
    ENDCASE
    :
    OTHERWISE
 CASE GET$ OF
     WHEN "R","r" : PROCdisplay
     OTHERWISE PROCdisplay
    ENDCASE
    :
ENDCASE
   :
ENDPROC
